From: Roland Häder Date: Sun, 3 Sep 2017 22:54:42 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=9456d01890f421b44d6f776c8230a43dc9b7e787;p=jcontacts-business-core.git Continued: - renamed branchCompanyContact -> branchCompany - added new entity field/property "branchContactEmployee", an employee may act as a contact person in this branch office - added first named query for branch office entity: "AllBranchOffices" - renamed package "branch" -> "branchoffice" - added event for when an administrator has added basic company data Signed-off-by: Roland Häder --- diff --git a/src/org/mxchange/jcontactsbusiness/basicdata/BusinessBasicData.java b/src/org/mxchange/jcontactsbusiness/basicdata/BusinessBasicData.java index 399b178..0314b60 100644 --- a/src/org/mxchange/jcontactsbusiness/basicdata/BusinessBasicData.java +++ b/src/org/mxchange/jcontactsbusiness/basicdata/BusinessBasicData.java @@ -19,9 +19,9 @@ package org.mxchange.jcontactsbusiness.basicdata; import java.io.Serializable; import java.util.Calendar; import java.util.List; -import org.mxchange.jcontactsbusiness.branch.BranchOffice; +import org.mxchange.jcontactsbusiness.branchoffice.BranchOffice; import org.mxchange.jcontactsbusiness.employee.Employee; -import org.mxchange.jcontactsbusiness.headquarters.HeadQuartersData; +import org.mxchange.jcontactsbusiness.headquarters.HeadquartersData; import org.mxchange.jcontactsbusiness.logo.BusinessLogo; import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber; import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber; @@ -67,14 +67,14 @@ public interface BusinessBasicData extends Serializable { *

* @return Business contact id */ - Long getBusinessDataId (); + Long getCompanyDataId (); /** * Setter for business contact id *

* @param businessContactId Business contact id */ - void setBusinessDataId (final Long businessContactId); + void setCompanyDataId (final Long businessContactId); /** * Getter for company founder @@ -95,42 +95,42 @@ public interface BusinessBasicData extends Serializable { *

* @return Headquarters data */ - HeadQuartersData getCompanyHeadQuartersData (); + HeadquartersData getCompanyHeadQuartersData (); /** * Setter for headquarters data *

* @param headQuartersData Headquarters data */ - void setCompanyHeadQuartersData (final HeadQuartersData headQuartersData); + void setCompanyHeadQuartersData (final HeadquartersData headQuartersData); /** * Getter for user owner instance *

* @return User owner instance */ - User getContactCompanyUserOwner (); + User getCompanyUserOwner (); /** * Setter for user owner instance *

* @param contactUserOwner User owner instance */ - void setContactCompanyUserOwner (final User contactUserOwner); + void setCompanyUserOwner (final User contactUserOwner); /** * Getter for timestamp when this entry has been created *

* @return Timestamp when this entry has been created */ - Calendar getContactCreated (); + Calendar getCompanyCreated (); /** * Setter for timestamp when this entry has been created *

* @param contactCreated Timestamp when this entry has been created */ - void setContactCreated (final Calendar contactCreated); + void setCompanyCreated (final Calendar contactCreated); /** * Getter for comments @@ -207,14 +207,14 @@ public interface BusinessBasicData extends Serializable { *

* @return Phone numbers */ - DialableLandLineNumber getCompanyPhoneNumber (); + DialableLandLineNumber getCompanyLandLineNumber (); /** * Setter for list of phone number *

* @param companyPhoneNumber Phone numbers */ - void setCompanyPhoneNumber (final DialableLandLineNumber companyPhoneNumber); + void setCompanyLandLineNumber (final DialableLandLineNumber companyPhoneNumber); /** * Getter for tax number diff --git a/src/org/mxchange/jcontactsbusiness/basicdata/CompanyBasicData.java b/src/org/mxchange/jcontactsbusiness/basicdata/CompanyBasicData.java index a5ebc01..171abd2 100644 --- a/src/org/mxchange/jcontactsbusiness/basicdata/CompanyBasicData.java +++ b/src/org/mxchange/jcontactsbusiness/basicdata/CompanyBasicData.java @@ -35,11 +35,11 @@ import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.persistence.Transient; -import org.mxchange.jcontactsbusiness.branch.BranchOffice; +import org.mxchange.jcontactsbusiness.branchoffice.BranchOffice; import org.mxchange.jcontactsbusiness.employee.CompanyEmployee; import org.mxchange.jcontactsbusiness.employee.Employee; -import org.mxchange.jcontactsbusiness.headquarters.CompanyHeadQuartersData; -import org.mxchange.jcontactsbusiness.headquarters.HeadQuartersData; +import org.mxchange.jcontactsbusiness.headquarters.CompanyHeadquartersData; +import org.mxchange.jcontactsbusiness.headquarters.HeadquartersData; import org.mxchange.jcontactsbusiness.logo.BusinessLogo; import org.mxchange.jcontactsbusiness.logo.CompanyLogo; import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber; @@ -58,8 +58,8 @@ import org.mxchange.jusercore.model.user.User; @Table (name = "company_basic_data") @NamedQueries ( { - @NamedQuery (name = "AllBusinessData", query = "SELECT b FROM company_basic_data AS b ORDER BY b.businessDataId"), - @NamedQuery (name = "SearchBusinessDataById", query = "SELECT b FROM company_basic_data AS b WHERE b.businessDataId = :businessDataId") + @NamedQuery (name = "AllBusinessData", query = "SELECT b FROM company_basic_data AS b ORDER BY b.companyDataId"), + @NamedQuery (name = "SearchBusinessDataById", query = "SELECT b FROM company_basic_data AS b WHERE b.companyDataId = :companyDataId") } ) @SuppressWarnings ("PersistenceUnitPresent") @@ -77,14 +77,6 @@ public class CompanyBasicData implements BusinessBasicData { @Transient private List brancheOffices; - /** - * Id number - */ - @Id - @Column (name = "business_data_id", nullable = false, updatable = false) - @GeneratedValue (strategy = GenerationType.IDENTITY) - private Long businessDataId; - /** * Comments (any) */ @@ -99,6 +91,22 @@ public class CompanyBasicData implements BusinessBasicData { @OneToOne (targetEntity = CompanyEmployee.class, cascade = CascadeType.ALL) private Employee companyContactEmployee; + /** + * Timestamp when this entry has been created + */ + @Basic (optional = false) + @Temporal (TemporalType.TIMESTAMP) + @Column (name = "company_entry_created", nullable = false, updatable = false) + private Calendar companyCreated; + + /** + * Id number + */ + @Id + @Column (name = "company_data_id", nullable = false, updatable = false) + @GeneratedValue (strategy = GenerationType.IDENTITY) + private Long companyDataId; + /** * Company's main email address (example: info@company.com) */ @@ -119,6 +127,20 @@ public class CompanyBasicData implements BusinessBasicData { @OneToOne (targetEntity = CompanyEmployee.class, cascade = CascadeType.ALL) private Employee companyFounder; + /** + * Reference to headquarters data + */ + @JoinColumn (name = "company_headquarters_data_id") + @OneToOne (targetEntity = CompanyHeadquartersData.class, cascade = CascadeType.ALL) + private HeadquartersData companyHeadQuartersData; + + /** + * Company's main phone number: +ccxxxxxxxxxx + */ + @JoinColumn (name = "company_landline_number_id") + @OneToOne (targetEntity = LandLineNumber.class, cascade = CascadeType.ALL) + private DialableLandLineNumber companyLandLineNumber; + /** * Id number of company logo */ @@ -130,22 +152,22 @@ public class CompanyBasicData implements BusinessBasicData { * Company name */ @Basic (optional = false) - @Column (name = "company_name", length = 100, nullable = false) + @Column (name = "company_name", length = 100, nullable = false, unique = true) private String companyName; - /** - * Company's main phone number: +ccxxxxxxxxxx - */ - @JoinColumn (name = "company_phone_number_id") - @OneToOne (targetEntity = LandLineNumber.class, cascade = CascadeType.ALL) - private DialableLandLineNumber companyPhoneNumber; - /** * Tax number */ @Column (name = "company_tax_number", length = 30) private String companyTaxNumber; + /** + * User owner instance + */ + @JoinColumn (name = "company_owner_user_id") + @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.REFRESH) + private User companyUserOwner; + /** * URL for company website */ @@ -153,26 +175,29 @@ public class CompanyBasicData implements BusinessBasicData { private String companyWebsiteUrl; /** - * User owner instance + * Default constructor, required for JPA */ - @JoinColumn (name = "company_owner_user_id") - @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.REFRESH) - private User contactCompanyUserOwner; + public CompanyBasicData () { + } /** - * Timestamp when this entry has been created + * Constructor with company name + *

+ * @param companyName Company name */ - @Basic (optional = false) - @Temporal (TemporalType.TIMESTAMP) - @Column (name = "company_entry_created", nullable = false, updatable = false) - private Calendar contactCreated; + public CompanyBasicData (final String companyName) { + // First, validate all parameter + if (companyName == null) { + // Is null + throw new NullPointerException("companyName is null"); //NOI18N + } else if (companyName.isEmpty()) { + // Is null + throw new IllegalArgumentException("companyName is empty"); //NOI18N + } - /** - * Reference to headquarters data - */ - @JoinColumn (name = "company_headquarters_data_id") - @OneToOne (targetEntity = CompanyHeadQuartersData.class, cascade = CascadeType.ALL) - private HeadQuartersData companyHeadQuartersData; + // Set company name + this.companyName = companyName; + } @Override public boolean equals (final Object object) { @@ -184,7 +209,7 @@ public class CompanyBasicData implements BusinessBasicData { final BusinessBasicData other = (BusinessBasicData) object; - if (!Objects.equals(this.getBusinessDataId(), other.getBusinessDataId())) { + if (!Objects.equals(this.getCompanyDataId(), other.getCompanyDataId())) { return false; } else if (!Objects.equals(this.getCompanyName(), other.getCompanyName())) { return false; @@ -211,16 +236,6 @@ public class CompanyBasicData implements BusinessBasicData { this.brancheOffices = brancheOffices; } - @Override - public Long getBusinessDataId () { - return this.businessDataId; - } - - @Override - public void setBusinessDataId (final Long businessDataId) { - this.businessDataId = businessDataId; - } - @Override public String getCompanyComments () { return this.companyComments; @@ -241,6 +256,28 @@ public class CompanyBasicData implements BusinessBasicData { this.companyContactEmployee = companyContactEmployee; } + @Override + @SuppressWarnings ("ReturnOfDateField") + public Calendar getCompanyCreated () { + return this.companyCreated; + } + + @Override + @SuppressWarnings ("AssignmentToDateFieldFromParameter") + public void setCompanyCreated (final Calendar companyCreated) { + this.companyCreated = companyCreated; + } + + @Override + public Long getCompanyDataId () { + return this.companyDataId; + } + + @Override + public void setCompanyDataId (final Long companyDataId) { + this.companyDataId = companyDataId; + } + @Override public String getCompanyEmailAddress () { return this.companyEmailAddress; @@ -272,92 +309,80 @@ public class CompanyBasicData implements BusinessBasicData { } @Override - public BusinessLogo getCompanyLogo () { - return this.companyLogo; - } - - @Override - public void setCompanyLogo (final BusinessLogo companyLogoId) { - this.companyLogo = companyLogoId; - } - - @Override - public String getCompanyName () { - return this.companyName; + public HeadquartersData getCompanyHeadQuartersData () { + return this.companyHeadQuartersData; } @Override - public void setCompanyName (final String companyName) { - this.companyName = companyName; + public void setCompanyHeadQuartersData (final HeadquartersData companyHeadQuartersData) { + this.companyHeadQuartersData = companyHeadQuartersData; } @Override - public DialableLandLineNumber getCompanyPhoneNumber () { - return this.companyPhoneNumber; + public DialableLandLineNumber getCompanyLandLineNumber () { + return this.companyLandLineNumber; } @Override - public void setCompanyPhoneNumber (final DialableLandLineNumber companyPhoneNumber) { - this.companyPhoneNumber = companyPhoneNumber; + public void setCompanyLandLineNumber (final DialableLandLineNumber companyLandLineNumber) { + this.companyLandLineNumber = companyLandLineNumber; } @Override - public String getCompanyTaxNumber () { - return this.companyTaxNumber; + public BusinessLogo getCompanyLogo () { + return this.companyLogo; } @Override - public void setCompanyTaxNumber (final String companyTaxNumber) { - this.companyTaxNumber = companyTaxNumber; + public void setCompanyLogo (final BusinessLogo companyLogoId) { + this.companyLogo = companyLogoId; } @Override - public String getCompanyWebsiteUrl () { - return this.companyWebsiteUrl; + public String getCompanyName () { + return this.companyName; } @Override - public void setCompanyWebsiteUrl (final String companyWebsiteUrl) { - this.companyWebsiteUrl = companyWebsiteUrl; + public void setCompanyName (final String companyName) { + this.companyName = companyName; } @Override - public User getContactCompanyUserOwner () { - return this.contactCompanyUserOwner; + public String getCompanyTaxNumber () { + return this.companyTaxNumber; } @Override - public void setContactCompanyUserOwner (final User contactCompanyUserOwner) { - this.contactCompanyUserOwner = contactCompanyUserOwner; + public void setCompanyTaxNumber (final String companyTaxNumber) { + this.companyTaxNumber = companyTaxNumber; } @Override - @SuppressWarnings ("ReturnOfDateField") - public Calendar getContactCreated () { - return this.contactCreated; + public User getCompanyUserOwner () { + return this.companyUserOwner; } @Override - @SuppressWarnings ("AssignmentToDateFieldFromParameter") - public void setContactCreated (final Calendar contactCreated) { - this.contactCreated = contactCreated; + public void setCompanyUserOwner (final User companyUserOwner) { + this.companyUserOwner = companyUserOwner; } @Override - public HeadQuartersData getCompanyHeadQuartersData () { - return this.companyHeadQuartersData; + public String getCompanyWebsiteUrl () { + return this.companyWebsiteUrl; } @Override - public void setCompanyHeadQuartersData (final HeadQuartersData companyHeadQuartersData) { - this.companyHeadQuartersData = companyHeadQuartersData; + public void setCompanyWebsiteUrl (final String companyWebsiteUrl) { + this.companyWebsiteUrl = companyWebsiteUrl; } @Override public int hashCode () { int hash = 3; - hash = 37 * hash + Objects.hashCode(this.getBusinessDataId()); + hash = 37 * hash + Objects.hashCode(this.getCompanyDataId()); hash = 37 * hash + Objects.hashCode(this.getCompanyName()); hash = 37 * hash + Objects.hashCode(this.getCompanyHeadQuartersData()); hash = 37 * hash + Objects.hashCode(this.getCompanyContactEmployee()); diff --git a/src/org/mxchange/jcontactsbusiness/branch/BranchOffice.java b/src/org/mxchange/jcontactsbusiness/branch/BranchOffice.java deleted file mode 100644 index be2c01f..0000000 --- a/src/org/mxchange/jcontactsbusiness/branch/BranchOffice.java +++ /dev/null @@ -1,235 +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 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jcontactsbusiness.branch; - -import java.io.Serializable; -import java.util.Calendar; -import org.mxchange.jcountry.data.Country; -import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber; -import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber; -import org.mxchange.jusercore.model.user.User; -import org.mxchange.jcontactsbusiness.basicdata.BusinessBasicData; - -/** - * A POJI for branch offices - *

- * @author Roland Häder - */ -public interface BranchOffice extends Serializable { - - /** - * Getter for branch office's city name - *

- * @return Branch office's city name - */ - String getBranchCity (); - - /** - * Setter for branch office's city name - *

- * @param branchCity Branch office's city name - */ - void setBranchCity (final String branchCity); - - /** - * Getter for branch office's email address - *

- * @return Branch office's email address - */ - String getBranchEmailAddress (); - - /** - * Setter for branch office's email address - *

- * @param branchEmailAddress Branch office's email address - */ - void setBranchEmailAddress (final String branchEmailAddress); - - /** - * Getter for branch office's fax number - *

- * @return Branch office's fax number - */ - DialableFaxNumber getBranchFaxNumber (); - - /** - * Setter for branch office's fax number - *

- * @param branchFaxNumber Branch office's fax number - */ - void setBranchFaxNumber (final DialableFaxNumber branchFaxNumber); - - /** - * Getter for branch office's house number - *

- * @return Branch office's house number - */ - Short getBranchHouseNumber (); - - /** - * Setter for branch office's house number - *

- * @param branchHouseNumber Branch office's house number - */ - void setBranchHouseNumber (final Short branchHouseNumber); - - /** - * Getter for branch office's phone number - *

- * @return Branch office's phone number - */ - DialableLandLineNumber getBranchPhoneNumber (); - - /** - * Setter for branch office's phone number - *

- * @param branchPhoneNumber Branch office's phone number - */ - void setBranchPhoneNumber (final DialableLandLineNumber branchPhoneNumber); - - /** - * Getter for branch office's store - *

- * @return Branch office's store - */ - Short getBranchStore (); - - /** - * Setter for branch office's store - *

- * @param branchStore Branch office's store - */ - void setBranchStore (final Short branchStore); - - /** - * Getter for branch office's street name - *

- * @return Branch office's street name - */ - String getBranchStreet (); - - /** - * Setter for branch office's street name - *

- * @param branchStreet Branch office's street name - */ - void setBranchStreet (final String branchStreet); - - /** - * Getter for branch office's suite number - *

- * @return Branch office's suite number - */ - Short getBranchSuiteNumber (); - - /** - * Setter for branch office's suite number - *

- * @param branchSuiteNumber Branch office's suite number - */ - void setBranchSuiteNumber (final Short branchSuiteNumber); - - /** - * Getter for branch office's ZIP code - *

- * @return Branch office's ZIP code - */ - Integer getBranchZipCode (); - - /** - * Setter for branch office's ZIP code - *

- * @param branchZipCode Branch office's ZIP code - */ - void setBranchZipCode (final Integer branchZipCode); - - /** - * Getter for branch office's id number - *

- * @return Branch office's id number - */ - Long getBranchId (); - - /** - * Setter for branch office's id number - *

- * @param branchId Branch office's id number - */ - void setBranchId (final Long branchId); - - /** - * Getter for branch office's country - *

- * @return Branch office's country - */ - Country getBranchCountry (); - - /** - * Setter for branch office's country - *

- * @param branchCountryCode Branch office's country - */ - void setBranchCountry (final Country branchCountryCode); - - /** - * Getter for branch office's company - *

- * @return Branch office's company - */ - BusinessBasicData getBranchCompanyContact (); - - /** - * Setter for branch office's company - *

- * @param branchCompanyContact Branch office's company - */ - void setBranchCompanyContact (final BusinessBasicData branchCompanyContact); - - /** - * Getter for user owner instance - *

- * @return User owner instance - */ - User getBranchUserOwner (); - - /** - * Setter for user owner instance - *

- * @param branchUserOwner User owner instance - */ - void setBranchUserOwner (final User branchUserOwner); - - /** - * Getter for timestamp when this entry has been created - *

- * @return Timestamp when this entry has been created - */ - Calendar getBranchCreated (); - - /** - * Setter for timestamp when this entry has been created - *

- * @param branchCreated Timestamp when this entry has been created - */ - void setBranchCreated (final Calendar branchCreated); - - @Override - boolean equals (final Object object); - - @Override - int hashCode (); -} diff --git a/src/org/mxchange/jcontactsbusiness/branch/CompanyBranchOffice.java b/src/org/mxchange/jcontactsbusiness/branch/CompanyBranchOffice.java deleted file mode 100644 index 4446eb2..0000000 --- a/src/org/mxchange/jcontactsbusiness/branch/CompanyBranchOffice.java +++ /dev/null @@ -1,347 +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 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jcontactsbusiness.branch; - -import java.util.Calendar; -import java.util.Objects; -import javax.persistence.Basic; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.OneToOne; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; -import javax.persistence.Transient; -import org.mxchange.jcontactsbusiness.basicdata.BusinessBasicData; -import org.mxchange.jcontactsbusiness.basicdata.CompanyBasicData; -import org.mxchange.jcountry.data.Country; -import org.mxchange.jcountry.data.CountryData; -import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber; -import org.mxchange.jphone.phonenumbers.fax.FaxNumber; -import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber; -import org.mxchange.jphone.phonenumbers.landline.LandLineNumber; -import org.mxchange.jusercore.model.user.LoginUser; -import org.mxchange.jusercore.model.user.User; - -/** - * A POJO for company branch offices - *

- * @author Roland Häder - */ -@Entity (name = "company_branch_offices") -@Table (name = "company_branch_offices") -@SuppressWarnings ("PersistenceUnitPresent") -public class CompanyBranchOffice implements BranchOffice { - - /** - * Serial number - */ - @Transient - private static final long serialVersionUID = 47_957_817_276_871_852L; - - /** - * Branch office's city name - */ - @Basic (optional = false) - @Column (name = "branch_city", length = 100, nullable = false) - private String branchCity; - - /** - * Company that has this branch office - */ - @JoinColumn (name = "branch_company_id", nullable = false, updatable = false) - @OneToOne (targetEntity = CompanyBasicData.class, optional = false, cascade = CascadeType.ALL) - private BusinessBasicData branchCompanyContact; - - /** - * Branch office's country code - */ - @JoinColumn (name = "branch_country_id", nullable = false) - @OneToOne (targetEntity = CountryData.class, cascade = CascadeType.REFRESH, optional = false) - private Country branchCountry; - - /** - * Timestamp when this entry has been created - */ - @Basic (optional = false) - @Temporal (TemporalType.TIMESTAMP) - @Column (name = "branch_entry_created", nullable = false, updatable = false) - private Calendar branchCreated; - - /** - * Branch office's main email address (example: branch-name@company.com) - */ - @Column (name = "branch_email_address", length = 100) - private String branchEmailAddress; - - /** - * Branch office's main fax number: +ccxxxxxxxxxx - */ - @JoinColumn (name = "branch_fax_number_id") - @OneToOne (targetEntity = FaxNumber.class, cascade = CascadeType.ALL) - private DialableFaxNumber branchFaxNumber; - - /** - * Branch office's house number - */ - @Basic (optional = false) - @Column (name = "branch_house_number", length = 3, nullable = false) - private Short branchHouseNumber; - - /** - * Id number - */ - @Id - @GeneratedValue (strategy = GenerationType.IDENTITY) - @Column (name = "branch_id", nullable = false, updatable = false) - private Long branchId; - - /** - * Branch office's main phone number: +ccxxxxxxxxxx - */ - @JoinColumn (name = "branch_phone_number_id") - @OneToOne (targetEntity = LandLineNumber.class, cascade = CascadeType.ALL) - private DialableLandLineNumber branchPhoneNumber; - - /** - * Branch office's store (if multiple-store building) - */ - @Column (name = "branch_store", length = 3) - private Short branchStore; - - /** - * Branch office's street name - */ - @Basic (optional = false) - @Column (name = "branch_street", length = 100, nullable = false) - private String branchStreet; - - /** - * Branch office's suite number (if applyable) - */ - @Column (name = "branch_suite_number", length = 4) - private Short branchSuiteNumber; - - /** - * User owner instance - */ - @JoinColumn (name = "branch_user_id") - @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.REFRESH) - private User branchUserOwner; - - /** - * Branch office's ZIP code - */ - @Basic (optional = false) - @Column (name = "branch_zip_code", length = 6, nullable = false) - private Integer branchZipCode; - - @Override - public boolean equals (final Object object) { - if (null == object) { - return false; - } else if (this.getClass() != object.getClass()) { - return false; - } - - final BranchOffice other = (BranchOffice) object; - - if (!Objects.equals(this.getBranchId(), other.getBranchId())) { - return false; - } else if (!Objects.equals(this.getBranchCity(), other.getBranchCity())) { - return false; - } else if (!Objects.equals(this.getBranchCountry(), other.getBranchCountry())) { - return false; - } else if (!Objects.equals(this.getBranchHouseNumber(), other.getBranchHouseNumber())) { - return false; - } else if (!Objects.equals(this.getBranchStore(), other.getBranchStore())) { - return false; - } else if (!Objects.equals(this.getBranchStreet(), other.getBranchStreet())) { - return false; - } else if (!Objects.equals(this.getBranchSuiteNumber(), other.getBranchSuiteNumber())) { - return false; - } else if (!Objects.equals(this.getBranchZipCode(), other.getBranchZipCode())) { - return false; - } - - return true; - } - - @Override - public String getBranchCity () { - return this.branchCity; - } - - @Override - public void setBranchCity (final String branchCity) { - this.branchCity = branchCity; - } - - @Override - public BusinessBasicData getBranchCompanyContact () { - return this.branchCompanyContact; - } - - @Override - public void setBranchCompanyContact (final BusinessBasicData branchCompanyContact) { - this.branchCompanyContact = branchCompanyContact; - } - - @Override - public Country getBranchCountry () { - return this.branchCountry; - } - - @Override - public void setBranchCountry (final Country branchCountry) { - this.branchCountry = branchCountry; - } - - @Override - @SuppressWarnings ("ReturnOfDateField") - public Calendar getBranchCreated () { - return this.branchCreated; - } - - @Override - @SuppressWarnings ("AssignmentToDateFieldFromParameter") - public void setBranchCreated (final Calendar branchCreated) { - this.branchCreated = branchCreated; - } - - @Override - public String getBranchEmailAddress () { - return this.branchEmailAddress; - } - - @Override - public void setBranchEmailAddress (final String branchEmailAddress) { - this.branchEmailAddress = branchEmailAddress; - } - - @Override - public DialableFaxNumber getBranchFaxNumber () { - return this.branchFaxNumber; - } - - @Override - public void setBranchFaxNumber (final DialableFaxNumber branchFaxNumber) { - this.branchFaxNumber = branchFaxNumber; - } - - @Override - public Short getBranchHouseNumber () { - return this.branchHouseNumber; - } - - @Override - public void setBranchHouseNumber (final Short branchHouseNumber) { - this.branchHouseNumber = branchHouseNumber; - } - - @Override - public Long getBranchId () { - return this.branchId; - } - - @Override - public void setBranchId (final Long branchId) { - this.branchId = branchId; - } - - @Override - public DialableLandLineNumber getBranchPhoneNumber () { - return this.branchPhoneNumber; - } - - @Override - public void setBranchPhoneNumber (final DialableLandLineNumber branchPhoneNumber) { - this.branchPhoneNumber = branchPhoneNumber; - } - - @Override - public Short getBranchStore () { - return this.branchStore; - } - - @Override - public void setBranchStore (final Short branchStore) { - this.branchStore = branchStore; - } - - @Override - public String getBranchStreet () { - return this.branchStreet; - } - - @Override - public void setBranchStreet (final String branchStreet) { - this.branchStreet = branchStreet; - } - - @Override - public Short getBranchSuiteNumber () { - return this.branchSuiteNumber; - } - - @Override - public void setBranchSuiteNumber (final Short branchSuiteNumber) { - this.branchSuiteNumber = branchSuiteNumber; - } - - @Override - public User getBranchUserOwner () { - return this.branchUserOwner; - } - - @Override - public void setBranchUserOwner (final User branchUserOwner) { - this.branchUserOwner = branchUserOwner; - } - - @Override - public Integer getBranchZipCode () { - return this.branchZipCode; - } - - @Override - public void setBranchZipCode (final Integer branchZipCode) { - this.branchZipCode = branchZipCode; - } - - @Override - public int hashCode () { - int hash = 7; - - hash = 53 * hash + Objects.hashCode(this.getBranchId()); - hash = 53 * hash + Objects.hashCode(this.getBranchCity()); - hash = 53 * hash + Objects.hashCode(this.getBranchCountry()); - hash = 53 * hash + Objects.hashCode(this.getBranchHouseNumber()); - hash = 53 * hash + Objects.hashCode(this.getBranchStore()); - hash = 53 * hash + Objects.hashCode(this.getBranchStreet()); - hash = 53 * hash + Objects.hashCode(this.getBranchSuiteNumber()); - hash = 53 * hash + Objects.hashCode(this.getBranchZipCode()); - - return hash; - } - -} diff --git a/src/org/mxchange/jcontactsbusiness/branchoffice/BranchOffice.java b/src/org/mxchange/jcontactsbusiness/branchoffice/BranchOffice.java new file mode 100644 index 0000000..5690040 --- /dev/null +++ b/src/org/mxchange/jcontactsbusiness/branchoffice/BranchOffice.java @@ -0,0 +1,250 @@ +/* + * 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 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.jcontactsbusiness.branchoffice; + +import java.io.Serializable; +import java.util.Calendar; +import org.mxchange.jcontactsbusiness.basicdata.BusinessBasicData; +import org.mxchange.jcontactsbusiness.employee.Employee; +import org.mxchange.jcountry.data.Country; +import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber; +import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber; +import org.mxchange.jusercore.model.user.User; + +/** + * A POJI for branch offices + *

+ * @author Roland Häder + */ +public interface BranchOffice extends Serializable { + + /** + * Getter for branch office's city name + *

+ * @return Branch office's city name + */ + String getBranchCity (); + + /** + * Setter for branch office's city name + *

+ * @param branchCity Branch office's city name + */ + void setBranchCity (final String branchCity); + + /** + * Getter for branch office's email address + *

+ * @return Branch office's email address + */ + String getBranchEmailAddress (); + + /** + * Setter for branch office's email address + *

+ * @param branchEmailAddress Branch office's email address + */ + void setBranchEmailAddress (final String branchEmailAddress); + + /** + * Getter for branch office's fax number + *

+ * @return Branch office's fax number + */ + DialableFaxNumber getBranchFaxNumber (); + + /** + * Setter for branch office's fax number + *

+ * @param branchFaxNumber Branch office's fax number + */ + void setBranchFaxNumber (final DialableFaxNumber branchFaxNumber); + + /** + * Getter for branch office's house number + *

+ * @return Branch office's house number + */ + Short getBranchHouseNumber (); + + /** + * Setter for branch office's house number + *

+ * @param branchHouseNumber Branch office's house number + */ + void setBranchHouseNumber (final Short branchHouseNumber); + + /** + * Getter for branch office's phone number + *

+ * @return Branch office's phone number + */ + DialableLandLineNumber getBranchPhoneNumber (); + + /** + * Setter for branch office's phone number + *

+ * @param branchPhoneNumber Branch office's phone number + */ + void setBranchPhoneNumber (final DialableLandLineNumber branchPhoneNumber); + + /** + * Getter for branch office's store + *

+ * @return Branch office's store + */ + Short getBranchStore (); + + /** + * Setter for branch office's store + *

+ * @param branchStore Branch office's store + */ + void setBranchStore (final Short branchStore); + + /** + * Getter for branch office's street name + *

+ * @return Branch office's street name + */ + String getBranchStreet (); + + /** + * Setter for branch office's street name + *

+ * @param branchStreet Branch office's street name + */ + void setBranchStreet (final String branchStreet); + + /** + * Getter for branch office's suite number + *

+ * @return Branch office's suite number + */ + Short getBranchSuiteNumber (); + + /** + * Setter for branch office's suite number + *

+ * @param branchSuiteNumber Branch office's suite number + */ + void setBranchSuiteNumber (final Short branchSuiteNumber); + + /** + * Getter for branch office's ZIP code + *

+ * @return Branch office's ZIP code + */ + Integer getBranchZipCode (); + + /** + * Setter for branch office's ZIP code + *

+ * @param branchZipCode Branch office's ZIP code + */ + void setBranchZipCode (final Integer branchZipCode); + + /** + * Getter for branch office's id number + *

+ * @return Branch office's id number + */ + Long getBranchId (); + + /** + * Setter for branch office's id number + *

+ * @param branchId Branch office's id number + */ + void setBranchId (final Long branchId); + + /** + * Getter for branch office's country + *

+ * @return Branch office's country + */ + Country getBranchCountry (); + + /** + * Setter for branch office's country + *

+ * @param branchCountryCode Branch office's country + */ + void setBranchCountry (final Country branchCountryCode); + + /** + * Getter for branch office's company + *

+ * @return Branch office's company + */ + BusinessBasicData getBranchCompany (); + + /** + * Setter for branch office's company + *

+ * @param branchCompany Branch office's company + */ + void setBranchCompany (final BusinessBasicData branchCompany); + + /** + * Getter branch office's contact person + *

+ * @return Branch office's contact person + */ + Employee getBranchContactEmployee (); + + /** + * Setter branch office's contact person + *

+ * @param branchEmployee Branch office's contact person + */ + void setBranchContactEmployee (final Employee branchEmployee); + + /** + * Getter for user owner instance + *

+ * @return User owner instance + */ + User getBranchUserOwner (); + + /** + * Setter for user owner instance + *

+ * @param branchUserOwner User owner instance + */ + void setBranchUserOwner (final User branchUserOwner); + + /** + * Getter for timestamp when this entry has been created + *

+ * @return Timestamp when this entry has been created + */ + Calendar getBranchCreated (); + + /** + * Setter for timestamp when this entry has been created + *

+ * @param branchCreated Timestamp when this entry has been created + */ + void setBranchCreated (final Calendar branchCreated); + + @Override + boolean equals (final Object object); + + @Override + int hashCode (); +} diff --git a/src/org/mxchange/jcontactsbusiness/branchoffice/CompanyBranchOffice.java b/src/org/mxchange/jcontactsbusiness/branchoffice/CompanyBranchOffice.java new file mode 100644 index 0000000..691b699 --- /dev/null +++ b/src/org/mxchange/jcontactsbusiness/branchoffice/CompanyBranchOffice.java @@ -0,0 +1,371 @@ +/* + * 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 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.jcontactsbusiness.branchoffice; + +import java.util.Calendar; +import java.util.Objects; +import javax.persistence.Basic; +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.OneToOne; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.Transient; +import org.mxchange.jcontactsbusiness.basicdata.BusinessBasicData; +import org.mxchange.jcontactsbusiness.basicdata.CompanyBasicData; +import org.mxchange.jcontactsbusiness.employee.CompanyEmployee; +import org.mxchange.jcontactsbusiness.employee.Employee; +import org.mxchange.jcountry.data.Country; +import org.mxchange.jcountry.data.CountryData; +import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber; +import org.mxchange.jphone.phonenumbers.fax.FaxNumber; +import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber; +import org.mxchange.jphone.phonenumbers.landline.LandLineNumber; +import org.mxchange.jusercore.model.user.LoginUser; +import org.mxchange.jusercore.model.user.User; + +/** + * A POJO for company branch offices + *

+ * @author Roland Häder + */ +@Entity (name = "company_branch_offices") +@Table (name = "company_branch_offices") +@NamedQueries ({ + @NamedQuery (name = "AllBranchOffices", query = "SELECT bo FROM company_branch_offices AS bo ORDER BY bo.branchId ASC") +}) +@SuppressWarnings ("PersistenceUnitPresent") +public class CompanyBranchOffice implements BranchOffice { + + /** + * Serial number + */ + @Transient + private static final long serialVersionUID = 47_957_817_276_871_852L; + + /** + * Branch office's city name + */ + @Basic (optional = false) + @Column (name = "branch_city", length = 100, nullable = false) + private String branchCity; + + /** + * Company that has this branch office + */ + @JoinColumn (name = "branch_company_id", nullable = false, updatable = false) + @OneToOne (targetEntity = CompanyBasicData.class, optional = false, cascade = CascadeType.ALL) + private BusinessBasicData branchCompany; + + /** + * Branch office's country code + */ + @JoinColumn (name = "branch_country_id", nullable = false) + @OneToOne (targetEntity = CountryData.class, cascade = CascadeType.REFRESH, optional = false) + private Country branchCountry; + + /** + * Timestamp when this entry has been created + */ + @Basic (optional = false) + @Temporal (TemporalType.TIMESTAMP) + @Column (name = "branch_entry_created", nullable = false, updatable = false) + private Calendar branchCreated; + + /** + * Branch office's main email address (example: branch-name@company.com) + */ + @Column (name = "branch_email_address", length = 100) + private String branchEmailAddress; + + /** + * Reference to contact person + */ + @JoinColumn (name = "branch_contact_employee_id") + @OneToOne (targetEntity = CompanyEmployee.class, cascade = CascadeType.ALL) + private Employee branchContactEmployee; + + /** + * Branch office's main fax number: +ccxxxxxxxxxx + */ + @JoinColumn (name = "branch_fax_number_id") + @OneToOne (targetEntity = FaxNumber.class, cascade = CascadeType.ALL) + private DialableFaxNumber branchFaxNumber; + + /** + * Branch office's house number + */ + @Basic (optional = false) + @Column (name = "branch_house_number", length = 3, nullable = false) + private Short branchHouseNumber; + + /** + * Id number + */ + @Id + @GeneratedValue (strategy = GenerationType.IDENTITY) + @Column (name = "branch_id", nullable = false, updatable = false) + private Long branchId; + + /** + * Branch office's main phone number: +ccxxxxxxxxxx + */ + @JoinColumn (name = "branch_phone_number_id") + @OneToOne (targetEntity = LandLineNumber.class, cascade = CascadeType.ALL) + private DialableLandLineNumber branchPhoneNumber; + + /** + * Branch office's store (if multiple-store building) + */ + @Column (name = "branch_store", length = 3) + private Short branchStore; + + /** + * Branch office's street name + */ + @Basic (optional = false) + @Column (name = "branch_street", length = 100, nullable = false) + private String branchStreet; + + /** + * Branch office's suite number (if applyable) + */ + @Column (name = "branch_suite_number", length = 4) + private Short branchSuiteNumber; + + /** + * User owner instance + */ + @JoinColumn (name = "branch_user_id") + @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.REFRESH) + private User branchUserOwner; + + /** + * Branch office's ZIP code + */ + @Basic (optional = false) + @Column (name = "branch_zip_code", length = 6, nullable = false) + private Integer branchZipCode; + + @Override + public boolean equals (final Object object) { + if (null == object) { + return false; + } else if (this.getClass() != object.getClass()) { + return false; + } + + final BranchOffice other = (BranchOffice) object; + + if (!Objects.equals(this.getBranchId(), other.getBranchId())) { + return false; + } else if (!Objects.equals(this.getBranchCity(), other.getBranchCity())) { + return false; + } else if (!Objects.equals(this.getBranchCountry(), other.getBranchCountry())) { + return false; + } else if (!Objects.equals(this.getBranchHouseNumber(), other.getBranchHouseNumber())) { + return false; + } else if (!Objects.equals(this.getBranchStore(), other.getBranchStore())) { + return false; + } else if (!Objects.equals(this.getBranchStreet(), other.getBranchStreet())) { + return false; + } else if (!Objects.equals(this.getBranchSuiteNumber(), other.getBranchSuiteNumber())) { + return false; + } else if (!Objects.equals(this.getBranchZipCode(), other.getBranchZipCode())) { + return false; + } + + return true; + } + + @Override + public String getBranchCity () { + return this.branchCity; + } + + @Override + public void setBranchCity (final String branchCity) { + this.branchCity = branchCity; + } + + @Override + public BusinessBasicData getBranchCompany () { + return this.branchCompany; + } + + @Override + public void setBranchCompany (final BusinessBasicData branchCompany) { + this.branchCompany = branchCompany; + } + + @Override + public Country getBranchCountry () { + return this.branchCountry; + } + + @Override + public void setBranchCountry (final Country branchCountry) { + this.branchCountry = branchCountry; + } + + @Override + @SuppressWarnings ("ReturnOfDateField") + public Calendar getBranchCreated () { + return this.branchCreated; + } + + @Override + @SuppressWarnings ("AssignmentToDateFieldFromParameter") + public void setBranchCreated (final Calendar branchCreated) { + this.branchCreated = branchCreated; + } + + @Override + public String getBranchEmailAddress () { + return this.branchEmailAddress; + } + + @Override + public void setBranchEmailAddress (final String branchEmailAddress) { + this.branchEmailAddress = branchEmailAddress; + } + + @Override + public Employee getBranchContactEmployee () { + return this.branchContactEmployee; + } + + @Override + public void setBranchContactEmployee (final Employee branchContactEmployee) { + this.branchContactEmployee = branchContactEmployee; + } + + @Override + public DialableFaxNumber getBranchFaxNumber () { + return this.branchFaxNumber; + } + + @Override + public void setBranchFaxNumber (final DialableFaxNumber branchFaxNumber) { + this.branchFaxNumber = branchFaxNumber; + } + + @Override + public Short getBranchHouseNumber () { + return this.branchHouseNumber; + } + + @Override + public void setBranchHouseNumber (final Short branchHouseNumber) { + this.branchHouseNumber = branchHouseNumber; + } + + @Override + public Long getBranchId () { + return this.branchId; + } + + @Override + public void setBranchId (final Long branchId) { + this.branchId = branchId; + } + + @Override + public DialableLandLineNumber getBranchPhoneNumber () { + return this.branchPhoneNumber; + } + + @Override + public void setBranchPhoneNumber (final DialableLandLineNumber branchPhoneNumber) { + this.branchPhoneNumber = branchPhoneNumber; + } + + @Override + public Short getBranchStore () { + return this.branchStore; + } + + @Override + public void setBranchStore (final Short branchStore) { + this.branchStore = branchStore; + } + + @Override + public String getBranchStreet () { + return this.branchStreet; + } + + @Override + public void setBranchStreet (final String branchStreet) { + this.branchStreet = branchStreet; + } + + @Override + public Short getBranchSuiteNumber () { + return this.branchSuiteNumber; + } + + @Override + public void setBranchSuiteNumber (final Short branchSuiteNumber) { + this.branchSuiteNumber = branchSuiteNumber; + } + + @Override + public User getBranchUserOwner () { + return this.branchUserOwner; + } + + @Override + public void setBranchUserOwner (final User branchUserOwner) { + this.branchUserOwner = branchUserOwner; + } + + @Override + public Integer getBranchZipCode () { + return this.branchZipCode; + } + + @Override + public void setBranchZipCode (final Integer branchZipCode) { + this.branchZipCode = branchZipCode; + } + + @Override + public int hashCode () { + int hash = 7; + + hash = 53 * hash + Objects.hashCode(this.getBranchId()); + hash = 53 * hash + Objects.hashCode(this.getBranchCity()); + hash = 53 * hash + Objects.hashCode(this.getBranchCountry()); + hash = 53 * hash + Objects.hashCode(this.getBranchHouseNumber()); + hash = 53 * hash + Objects.hashCode(this.getBranchStore()); + hash = 53 * hash + Objects.hashCode(this.getBranchStreet()); + hash = 53 * hash + Objects.hashCode(this.getBranchSuiteNumber()); + hash = 53 * hash + Objects.hashCode(this.getBranchZipCode()); + + return hash; + } + +} diff --git a/src/org/mxchange/jcontactsbusiness/department/CompanyDepartment.java b/src/org/mxchange/jcontactsbusiness/department/CompanyDepartment.java index 3e74a6e..e49a2ce 100644 --- a/src/org/mxchange/jcontactsbusiness/department/CompanyDepartment.java +++ b/src/org/mxchange/jcontactsbusiness/department/CompanyDepartment.java @@ -33,15 +33,15 @@ import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.persistence.Transient; import org.mxchange.jcontactsbusiness.basicdata.CompanyBasicData; -import org.mxchange.jcontactsbusiness.branch.BranchOffice; -import org.mxchange.jcontactsbusiness.branch.CompanyBranchOffice; +import org.mxchange.jcontactsbusiness.branchoffice.BranchOffice; +import org.mxchange.jcontactsbusiness.branchoffice.CompanyBranchOffice; import org.mxchange.jcontactsbusiness.employee.CompanyEmployee; import org.mxchange.jcontactsbusiness.employee.Employee; -import org.mxchange.jcontactsbusiness.headquarters.CompanyHeadQuartersData; -import org.mxchange.jcontactsbusiness.headquarters.HeadQuartersData; +import org.mxchange.jcontactsbusiness.headquarters.CompanyHeadquartersData; import org.mxchange.jusercore.model.user.LoginUser; import org.mxchange.jusercore.model.user.User; import org.mxchange.jcontactsbusiness.basicdata.BusinessBasicData; +import org.mxchange.jcontactsbusiness.headquarters.HeadquartersData; /** * A POJO for company departments @@ -63,8 +63,8 @@ public class CompanyDepartment implements Department { * Where this department is located */ @JoinColumn (name = "department_headquarters_id") - @OneToOne (targetEntity = CompanyHeadQuartersData.class, cascade = CascadeType.ALL) - private HeadQuartersData departentHeadquarters; + @OneToOne (targetEntity = CompanyHeadquartersData.class, cascade = CascadeType.ALL) + private HeadquartersData departentHeadquarters; /** * Where this department is located @@ -139,12 +139,12 @@ public class CompanyDepartment implements Department { } @Override - public HeadQuartersData getDepartentHeadquarters () { + public HeadquartersData getDepartentHeadquarters () { return this.departentHeadquarters; } @Override - public void setDepartentHeadquarters (final HeadQuartersData departentHeadquarters) { + public void setDepartentHeadquarters (final HeadquartersData departentHeadquarters) { this.departentHeadquarters = departentHeadquarters; } diff --git a/src/org/mxchange/jcontactsbusiness/department/Department.java b/src/org/mxchange/jcontactsbusiness/department/Department.java index 1615f98..433b1f4 100644 --- a/src/org/mxchange/jcontactsbusiness/department/Department.java +++ b/src/org/mxchange/jcontactsbusiness/department/Department.java @@ -18,11 +18,11 @@ package org.mxchange.jcontactsbusiness.department; import java.io.Serializable; import java.util.Calendar; -import org.mxchange.jcontactsbusiness.branch.BranchOffice; +import org.mxchange.jcontactsbusiness.branchoffice.BranchOffice; import org.mxchange.jcontactsbusiness.employee.Employee; -import org.mxchange.jcontactsbusiness.headquarters.HeadQuartersData; import org.mxchange.jusercore.model.user.User; import org.mxchange.jcontactsbusiness.basicdata.BusinessBasicData; +import org.mxchange.jcontactsbusiness.headquarters.HeadquartersData; /** * A POJI for company departments @@ -50,14 +50,14 @@ public interface Department extends Serializable { *

* @return Connection to company headquarters */ - HeadQuartersData getDepartentHeadquarters (); + HeadquartersData getDepartentHeadquarters (); /** * Setter for connection to company headquarters *

* @param departentHeadquarters Connection to company headquarters */ - void setDepartentHeadquarters (final HeadQuartersData departentHeadquarters); + void setDepartentHeadquarters (final HeadquartersData departentHeadquarters); /** * Getter for connection to company branch office diff --git a/src/org/mxchange/jcontactsbusiness/employee/CompanyEmployee.java b/src/org/mxchange/jcontactsbusiness/employee/CompanyEmployee.java index e702921..0e8fe24 100644 --- a/src/org/mxchange/jcontactsbusiness/employee/CompanyEmployee.java +++ b/src/org/mxchange/jcontactsbusiness/employee/CompanyEmployee.java @@ -26,6 +26,8 @@ import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; import javax.persistence.OneToOne; import javax.persistence.Table; import javax.persistence.Temporal; @@ -35,12 +37,12 @@ import org.mxchange.jcontacts.contact.Contact; import org.mxchange.jcontacts.contact.UserContact; import org.mxchange.jcontactsbusiness.basicdata.BusinessBasicData; import org.mxchange.jcontactsbusiness.basicdata.CompanyBasicData; -import org.mxchange.jcontactsbusiness.branch.BranchOffice; -import org.mxchange.jcontactsbusiness.branch.CompanyBranchOffice; +import org.mxchange.jcontactsbusiness.branchoffice.BranchOffice; +import org.mxchange.jcontactsbusiness.branchoffice.CompanyBranchOffice; import org.mxchange.jcontactsbusiness.department.CompanyDepartment; import org.mxchange.jcontactsbusiness.department.Department; -import org.mxchange.jcontactsbusiness.headquarters.CompanyHeadQuartersData; -import org.mxchange.jcontactsbusiness.headquarters.HeadQuartersData; +import org.mxchange.jcontactsbusiness.headquarters.CompanyHeadquartersData; +import org.mxchange.jcontactsbusiness.headquarters.HeadquartersData; import org.mxchange.jcontactsbusiness.jobposition.EmployeePosition; import org.mxchange.jcontactsbusiness.jobposition.JobPosition; import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber; @@ -55,6 +57,12 @@ import org.mxchange.jusercore.model.user.User; */ @Entity (name = "company_employees") @Table (name = "company_employees") +@NamedQueries ( + { + @NamedQuery (name = "AllCompanyEmployees", query = "SELECT e FROM company_employees AS e ORDER BY e.employeeId ASC"), + @NamedQuery (name = "SearchCompanyEmployeeById", query = "SELECT e FROM company_employees AS e WHERE e.employeeId = :employeeId") + } +) @SuppressWarnings ("PersistenceUnitPresent") public class CompanyEmployee implements Employee { @@ -103,8 +111,8 @@ public class CompanyEmployee implements Employee { * Head quarters id number (if the employee works there) */ @JoinColumn (name = "employee_headquarters_id") - @OneToOne (targetEntity = CompanyHeadQuartersData.class, cascade = CascadeType.ALL) - private HeadQuartersData employeeHeadquarter; + @OneToOne (targetEntity = CompanyHeadquartersData.class, cascade = CascadeType.ALL) + private HeadquartersData employeeHeadquarter; /** * Id number @@ -230,12 +238,12 @@ public class CompanyEmployee implements Employee { } @Override - public HeadQuartersData getEmployeeHeadquarter () { + public HeadquartersData getEmployeeHeadquarter () { return this.employeeHeadquarter; } @Override - public void setEmployeeHeadquarter (final HeadQuartersData employeeHeadquarter) { + public void setEmployeeHeadquarter (final HeadquartersData employeeHeadquarter) { this.employeeHeadquarter = employeeHeadquarter; } diff --git a/src/org/mxchange/jcontactsbusiness/employee/Employee.java b/src/org/mxchange/jcontactsbusiness/employee/Employee.java index 2bf18ec..5da72e1 100644 --- a/src/org/mxchange/jcontactsbusiness/employee/Employee.java +++ b/src/org/mxchange/jcontactsbusiness/employee/Employee.java @@ -20,12 +20,12 @@ import java.io.Serializable; import java.util.Calendar; import org.mxchange.jcontacts.contact.Contact; import org.mxchange.jcontactsbusiness.basicdata.BusinessBasicData; -import org.mxchange.jcontactsbusiness.branch.BranchOffice; +import org.mxchange.jcontactsbusiness.branchoffice.BranchOffice; import org.mxchange.jcontactsbusiness.department.Department; -import org.mxchange.jcontactsbusiness.headquarters.HeadQuartersData; import org.mxchange.jcontactsbusiness.jobposition.JobPosition; import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber; import org.mxchange.jusercore.model.user.User; +import org.mxchange.jcontactsbusiness.headquarters.HeadquartersData; /** * A POJI for employees @@ -81,14 +81,14 @@ public interface Employee extends Serializable { *

* @return Employee's head quarters */ - HeadQuartersData getEmployeeHeadquarter (); + HeadquartersData getEmployeeHeadquarter (); /** * Getter for employee's head quarters *

* @param employeeHeadquarter Employee's head quarters */ - void setEmployeeHeadquarter (final HeadQuartersData employeeHeadquarter); + void setEmployeeHeadquarter (final HeadquartersData employeeHeadquarter); /** * Getter for employee's email address diff --git a/src/org/mxchange/jcontactsbusiness/events/basicdata/added/AdminAddedBusinessBasicDataEvent.java b/src/org/mxchange/jcontactsbusiness/events/basicdata/added/AdminAddedBusinessBasicDataEvent.java new file mode 100644 index 0000000..6726d65 --- /dev/null +++ b/src/org/mxchange/jcontactsbusiness/events/basicdata/added/AdminAddedBusinessBasicDataEvent.java @@ -0,0 +1,73 @@ +/* + * 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 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.jcontactsbusiness.events.basicdata.added; + +import java.text.MessageFormat; +import org.mxchange.jcontactsbusiness.basicdata.BusinessBasicData; + +/** + * An event being thrown when new basic business data has been added. + *

+ * @author Roland Häder + */ +public class AdminAddedBusinessBasicDataEvent implements ObservableAdminAddedBusinessBasicDataEvent { + + /** + * Serial number + */ + private static final long serialVersionUID = 41_908_266_873_657_271L; + + /** + * Basic data instance just being created. It must bear aside company name + * also a primary key. + */ + private final BusinessBasicData basicData; + + /** + * Constructor with basic data + *

+ * @param basicData Basic data with at least company name and primary key + */ + public AdminAddedBusinessBasicDataEvent (final BusinessBasicData basicData) { + // Is company name and primary key set? + if (null == basicData) { + // Throw NPE + throw new NullPointerException("basicData is null"); //NOI18N + } else if (basicData.getCompanyName() == null) { + // Throw NPE again + throw new NullPointerException("basicData.companyName is null"); //NOI18N + } else if (basicData.getCompanyName().isEmpty()) { + // Throw NPE again + throw new IllegalArgumentException("basicData.companyName is empty"); //NOI18N + } else if (basicData.getCompanyDataId() == null) { + // Throw NPE again + throw new NullPointerException("basicData.companyDataId is null"); //NOI18N + } else if (basicData.getCompanyDataId() < 1) { + // Throw NPE again + throw new IllegalArgumentException(MessageFormat.format("basicData.companyDataId={0} is not valid.", basicData.getCompanyDataId())); //NOI18N + } + + // Set it here + this.basicData = basicData; + } + + @Override + public BusinessBasicData getBasicData () { + return this.basicData; + } + +} diff --git a/src/org/mxchange/jcontactsbusiness/events/basicdata/added/ObservableAdminAddedBusinessBasicDataEvent.java b/src/org/mxchange/jcontactsbusiness/events/basicdata/added/ObservableAdminAddedBusinessBasicDataEvent.java new file mode 100644 index 0000000..9bec912 --- /dev/null +++ b/src/org/mxchange/jcontactsbusiness/events/basicdata/added/ObservableAdminAddedBusinessBasicDataEvent.java @@ -0,0 +1,37 @@ +/* + * 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 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.jcontactsbusiness.events.basicdata.added; + +import java.io.Serializable; +import org.mxchange.jcontactsbusiness.basicdata.BusinessBasicData; + +/** + * An interface for events being fired when new basic business data has been + * added. + *

+ * @author Roland Häder + */ +public interface ObservableAdminAddedBusinessBasicDataEvent extends Serializable { + + /** + * Getter for basic business data entity + *

+ * @return Basic business data entity + */ + BusinessBasicData getBasicData (); + +} diff --git a/src/org/mxchange/jcontactsbusiness/exceptions/basicdata/BusinessDataAlreadyAddedException.java b/src/org/mxchange/jcontactsbusiness/exceptions/basicdata/BusinessDataAlreadyAddedException.java index a60459c..4137059 100644 --- a/src/org/mxchange/jcontactsbusiness/exceptions/basicdata/BusinessDataAlreadyAddedException.java +++ b/src/org/mxchange/jcontactsbusiness/exceptions/basicdata/BusinessDataAlreadyAddedException.java @@ -37,14 +37,14 @@ public class BusinessDataAlreadyAddedException extends Exception { * @param businessContact Business contact that is already added */ public BusinessDataAlreadyAddedException (final BusinessBasicData businessContact) { - super(MessageFormat.format("Business contact with businessContactId={0} not found.", businessContact.getBusinessDataId())); //NOI18N + super(MessageFormat.format("Business contact with comanyName={0} already added.", businessContact.getCompanyName())); //NOI18N } /** * Default constructor, may be used if no contact instance is available */ public BusinessDataAlreadyAddedException () { - super("BusinessContact already added"); //NOI18N + super("Business contact already added"); //NOI18N } } diff --git a/src/org/mxchange/jcontactsbusiness/exceptions/employee/CompanyEmployeeNotFoundException.java b/src/org/mxchange/jcontactsbusiness/exceptions/employee/CompanyEmployeeNotFoundException.java index 40ac5a4..6e44956 100644 --- a/src/org/mxchange/jcontactsbusiness/exceptions/employee/CompanyEmployeeNotFoundException.java +++ b/src/org/mxchange/jcontactsbusiness/exceptions/employee/CompanyEmployeeNotFoundException.java @@ -19,7 +19,7 @@ package org.mxchange.jcontactsbusiness.exceptions.employee; import java.text.MessageFormat; /** - * An exception thrown when a contact (entity) has not found. + * An exception thrown when a company employee (entity) has not found. *

* @author Roland Häder */ diff --git a/src/org/mxchange/jcontactsbusiness/exceptions/headquarters/CompanyHeadquartersNotFoundException.java b/src/org/mxchange/jcontactsbusiness/exceptions/headquarters/CompanyHeadquartersNotFoundException.java new file mode 100644 index 0000000..ce1799c --- /dev/null +++ b/src/org/mxchange/jcontactsbusiness/exceptions/headquarters/CompanyHeadquartersNotFoundException.java @@ -0,0 +1,65 @@ +/* + * 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 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.jcontactsbusiness.exceptions.headquarters; + +import java.text.MessageFormat; + +/** + * An exception thrown when a headquarters (entity) has not found. + *

+ * @author Roland Häder + */ +public class CompanyHeadquartersNotFoundException extends Exception { + + /** + * Serial number + */ + private static final long serialVersionUID = 23_759_801_876_416_568L; + + /** + * Constructor with company headquarters id + *

+ * @param headquartersId Company headquarters id + */ + public CompanyHeadquartersNotFoundException (final Long headquartersId) { + // Call super constructor with message and cause + super(MessageFormat.format("Company headquarters with id {0} was not found.", headquartersId)); //NOI18N + } + + /** + * Constructor with company headquarters id and causing exception + *

+ * @param headquartersId Company headquarters id + * @param cause Causing exception + */ + public CompanyHeadquartersNotFoundException (final Long headquartersId, final Throwable cause) { + // Call super constructor with message and cause + super(MessageFormat.format("Company headquarters with id {0} was not found.", headquartersId), cause); //NOI18N + } + + /** + * Constructor with email address and causing exception + *

+ * @param emailAddress Email address + * @param cause Causing exception + */ + public CompanyHeadquartersNotFoundException (final String emailAddress, final Throwable cause) { + // Call super constructor with message and cause + super(MessageFormat.format("Company headquarters with email address {0} was not found.", emailAddress), cause); //NOI18N + } + +} diff --git a/src/org/mxchange/jcontactsbusiness/headquarters/CompanyHeadQuartersData.java b/src/org/mxchange/jcontactsbusiness/headquarters/CompanyHeadQuartersData.java deleted file mode 100644 index 0349a23..0000000 --- a/src/org/mxchange/jcontactsbusiness/headquarters/CompanyHeadQuartersData.java +++ /dev/null @@ -1,312 +0,0 @@ -/* - * Copyright (C) 2016 KLC - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jcontactsbusiness.headquarters; - -import java.util.Calendar; -import java.util.Objects; -import javax.persistence.Basic; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.OneToOne; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; -import javax.persistence.Transient; -import org.mxchange.jcountry.data.Country; -import org.mxchange.jcountry.data.CountryData; -import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber; -import org.mxchange.jphone.phonenumbers.fax.FaxNumber; -import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber; -import org.mxchange.jphone.phonenumbers.landline.LandLineNumber; -import org.mxchange.jusercore.model.user.LoginUser; -import org.mxchange.jusercore.model.user.User; - -/** - * A POJO for company headquarts data - *

- * @author Roland Häder - */ -@Entity (name = "company_headquarters") -@Table (name = "company_headquarters") -@SuppressWarnings ("PersistenceUnitPresent") -public class CompanyHeadQuartersData implements HeadQuartersData { - - /** - * Serial number - */ - @Transient - private static final long serialVersionUID = 385_752_948_781_761L; - - /** - * Headquarters' city name - */ - @Basic (optional = false) - @Column (name = "headquarters_city", length = 100, nullable = false) - private String headquartersCity; - - /** - * Headquarter's country code - */ - @JoinColumn (name = "headquarters_country_id", nullable = false) - @OneToOne (targetEntity = CountryData.class, cascade = CascadeType.REFRESH, optional = false) - private Country headquartersCountry; - - /** - * Timestamp when this entry has been created - */ - @Basic (optional = false) - @Temporal (TemporalType.TIMESTAMP) - @Column (name = "headquarters_entry_created", nullable = false, updatable = false) - private Calendar headquartersCreated; - - /** - * Headquarters' fax number - */ - @JoinColumn (name = "headquarters_fax_number_id") - @OneToOne (targetEntity = FaxNumber.class, cascade = CascadeType.ALL) - private DialableFaxNumber headquartersFaxNumber; - - /** - * Headquarters' house number - */ - @Basic (optional = false) - @Column (name = "headquarters_house_number", length = 4, nullable = false) - private Short headquartersHouseNumber; - - /** - * Id number - */ - @Id - @GeneratedValue (strategy = GenerationType.IDENTITY) - @Column (name = "headquarters_id", nullable = false, updatable = false) - private Long headquartersId; - - /** - * Headquarters' phone number - */ - @JoinColumn (name = "headquarters_phone_number_id") - @OneToOne (targetEntity = LandLineNumber.class, cascade = CascadeType.ALL) - private DialableLandLineNumber headquartersPhoneNumber; - - /** - * Headquarters' store number (multi-store building only) - */ - @Column (name = "headquarters_store", length = 3) - private Short headquartersStore; - - /** - * Headquarters' street name - */ - @Basic (optional = false) - @Column (name = "headquarters_street", length = 100, nullable = false) - private String headquartersStreet; - - /** - * Headquarters' suite number - */ - @Column (name = "headquarters_suite_number", length = 4) - private Short headquartersSuiteNumber; - - /** - * User owner instance - */ - @JoinColumn (name = "headquarters_user_id", nullable = false, updatable = false) - @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.REFRESH, optional = false) - private User headquartersUserOwner; - - /** - * Headquarters' ZIP code - */ - @Basic (optional = false) - @Column (name = "headquarters_zip_code", length = 6, nullable = false) - private Integer headquartersZipCode; - - @Override - public boolean equals (final Object object) { - if (null == object) { - return false; - } else if (this.getClass() != object.getClass()) { - return false; - } - - final HeadQuartersData other = (HeadQuartersData) object; - - if (!Objects.equals(this.getHeadquartersId(), other.getHeadquartersId())) { - return false; - } else if (!Objects.equals(this.getHeadquartersCity(), other.getHeadquartersCity())) { - return false; - } else if (!Objects.equals(this.getHeadquartersCountry(), other.getHeadquartersCountry())) { - return false; - } else if (!Objects.equals(this.getHeadquartersHouseNumber(), other.getHeadquartersHouseNumber())) { - return false; - } else if (!Objects.equals(this.getHeadquartersStore(), other.getHeadquartersStore())) { - return false; - } else if (!Objects.equals(this.getHeadquartersStreet(), other.getHeadquartersStreet())) { - return false; - } else if (!Objects.equals(this.getHeadquartersSuiteNumber(), other.getHeadquartersSuiteNumber())) { - return false; - } else if (!Objects.equals(this.getHeadquartersZipCode(), other.getHeadquartersZipCode())) { - return false; - } - - return true; - } - - @Override - public String getHeadquartersCity () { - return this.headquartersCity; - } - - @Override - public void setHeadquartersCity (final String headquartersCity) { - this.headquartersCity = headquartersCity; - } - - @Override - public Country getHeadquartersCountry () { - return this.headquartersCountry; - } - - @Override - public void setHeadquartersCountry (final Country headquartersCountry) { - this.headquartersCountry = headquartersCountry; - } - - @Override - @SuppressWarnings ("ReturnOfDateField") - public Calendar getHeadquartersCreated () { - return this.headquartersCreated; - } - - @Override - @SuppressWarnings ("AssignmentToDateFieldFromParameter") - public void setHeadquartersCreated (final Calendar headquartersCreated) { - this.headquartersCreated = headquartersCreated; - } - - @Override - public DialableFaxNumber getHeadquartersFaxNumber () { - return this.headquartersFaxNumber; - } - - @Override - public void setHeadquartersFaxNumber (final DialableFaxNumber headquartersFaxNumber) { - this.headquartersFaxNumber = headquartersFaxNumber; - } - - @Override - public Short getHeadquartersHouseNumber () { - return this.headquartersHouseNumber; - } - - @Override - public void setHeadquartersHouseNumber (final Short headquartersHouseNumber) { - this.headquartersHouseNumber = headquartersHouseNumber; - } - - @Override - public Long getHeadquartersId () { - return this.headquartersId; - } - - @Override - public void setHeadquartersId (final Long headquartersId) { - this.headquartersId = headquartersId; - } - - @Override - public DialableLandLineNumber getHeadquartersPhoneNumber () { - return this.headquartersPhoneNumber; - } - - @Override - public void setHeadquartersPhoneNumber (final DialableLandLineNumber headquartersPhoneNumber) { - this.headquartersPhoneNumber = headquartersPhoneNumber; - } - - @Override - public Short getHeadquartersStore () { - return this.headquartersStore; - } - - @Override - public void setHeadquartersStore (final Short headquartersStore) { - this.headquartersStore = headquartersStore; - } - - @Override - public String getHeadquartersStreet () { - return this.headquartersStreet; - } - - @Override - public void setHeadquartersStreet (final String headquartersStreet) { - this.headquartersStreet = headquartersStreet; - } - - @Override - public Short getHeadquartersSuiteNumber () { - return this.headquartersSuiteNumber; - } - - @Override - public void setHeadquartersSuiteNumber (final Short headquartersSuiteNumber) { - this.headquartersSuiteNumber = headquartersSuiteNumber; - } - - @Override - public User getHeadquartersUserOwner () { - return this.headquartersUserOwner; - } - - @Override - public void setHeadquartersUserOwner (final User headquartersUserOwner) { - this.headquartersUserOwner = headquartersUserOwner; - } - - @Override - public Integer getHeadquartersZipCode () { - return this.headquartersZipCode; - } - - @Override - public void setHeadquartersZipCode (final Integer headquartersZipCode) { - this.headquartersZipCode = headquartersZipCode; - } - - @Override - public int hashCode () { - int hash = 7; - - hash = 47 * hash + Objects.hashCode(this.getHeadquartersId()); - hash = 47 * hash + Objects.hashCode(this.getHeadquartersCity()); - hash = 47 * hash + Objects.hashCode(this.getHeadquartersCountry()); - hash = 47 * hash + Objects.hashCode(this.getHeadquartersHouseNumber()); - hash = 47 * hash + Objects.hashCode(this.getHeadquartersStore()); - hash = 47 * hash + Objects.hashCode(this.getHeadquartersStreet()); - hash = 47 * hash + Objects.hashCode(this.getHeadquartersSuiteNumber()); - hash = 47 * hash + Objects.hashCode(this.getHeadquartersZipCode()); - - return hash; - } - -} diff --git a/src/org/mxchange/jcontactsbusiness/headquarters/CompanyHeadquartersData.java b/src/org/mxchange/jcontactsbusiness/headquarters/CompanyHeadquartersData.java new file mode 100644 index 0000000..0bafa1f --- /dev/null +++ b/src/org/mxchange/jcontactsbusiness/headquarters/CompanyHeadquartersData.java @@ -0,0 +1,312 @@ +/* + * Copyright (C) 2016 KLC + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.jcontactsbusiness.headquarters; + +import java.util.Calendar; +import java.util.Objects; +import javax.persistence.Basic; +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.OneToOne; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.Transient; +import org.mxchange.jcountry.data.Country; +import org.mxchange.jcountry.data.CountryData; +import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber; +import org.mxchange.jphone.phonenumbers.fax.FaxNumber; +import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber; +import org.mxchange.jphone.phonenumbers.landline.LandLineNumber; +import org.mxchange.jusercore.model.user.LoginUser; +import org.mxchange.jusercore.model.user.User; + +/** + * A POJO for company headquarts data + *

+ * @author Roland Häder + */ +@Entity (name = "company_headquarters") +@Table (name = "company_headquarters") +@SuppressWarnings ("PersistenceUnitPresent") +public class CompanyHeadquartersData implements HeadquartersData { + + /** + * Serial number + */ + @Transient + private static final long serialVersionUID = 385_752_948_781_761L; + + /** + * Headquarters' city name + */ + @Basic (optional = false) + @Column (name = "headquarters_city", length = 100, nullable = false) + private String headquartersCity; + + /** + * Headquarter's country code + */ + @JoinColumn (name = "headquarters_country_id", nullable = false) + @OneToOne (targetEntity = CountryData.class, cascade = CascadeType.REFRESH, optional = false) + private Country headquartersCountry; + + /** + * Timestamp when this entry has been created + */ + @Basic (optional = false) + @Temporal (TemporalType.TIMESTAMP) + @Column (name = "headquarters_entry_created", nullable = false, updatable = false) + private Calendar headquartersCreated; + + /** + * Headquarters' fax number + */ + @JoinColumn (name = "headquarters_fax_number_id") + @OneToOne (targetEntity = FaxNumber.class, cascade = CascadeType.ALL) + private DialableFaxNumber headquartersFaxNumber; + + /** + * Headquarters' house number + */ + @Basic (optional = false) + @Column (name = "headquarters_house_number", length = 4, nullable = false) + private Short headquartersHouseNumber; + + /** + * Id number + */ + @Id + @GeneratedValue (strategy = GenerationType.IDENTITY) + @Column (name = "headquarters_id", nullable = false, updatable = false) + private Long headquartersId; + + /** + * Headquarters' phone number + */ + @JoinColumn (name = "headquarters_phone_number_id") + @OneToOne (targetEntity = LandLineNumber.class, cascade = CascadeType.ALL) + private DialableLandLineNumber headquartersPhoneNumber; + + /** + * Headquarters' store number (multi-store building only) + */ + @Column (name = "headquarters_store", length = 3) + private Short headquartersStore; + + /** + * Headquarters' street name + */ + @Basic (optional = false) + @Column (name = "headquarters_street", length = 100, nullable = false) + private String headquartersStreet; + + /** + * Headquarters' suite number + */ + @Column (name = "headquarters_suite_number", length = 4) + private Short headquartersSuiteNumber; + + /** + * User owner instance + */ + @JoinColumn (name = "headquarters_user_id", nullable = false, updatable = false) + @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.REFRESH, optional = false) + private User headquartersUserOwner; + + /** + * Headquarters' ZIP code + */ + @Basic (optional = false) + @Column (name = "headquarters_zip_code", length = 6, nullable = false) + private Integer headquartersZipCode; + + @Override + public boolean equals (final Object object) { + if (null == object) { + return false; + } else if (this.getClass() != object.getClass()) { + return false; + } + + final HeadquartersData other = (HeadquartersData) object; + + if (!Objects.equals(this.getHeadquartersId(), other.getHeadquartersId())) { + return false; + } else if (!Objects.equals(this.getHeadquartersCity(), other.getHeadquartersCity())) { + return false; + } else if (!Objects.equals(this.getHeadquartersCountry(), other.getHeadquartersCountry())) { + return false; + } else if (!Objects.equals(this.getHeadquartersHouseNumber(), other.getHeadquartersHouseNumber())) { + return false; + } else if (!Objects.equals(this.getHeadquartersStore(), other.getHeadquartersStore())) { + return false; + } else if (!Objects.equals(this.getHeadquartersStreet(), other.getHeadquartersStreet())) { + return false; + } else if (!Objects.equals(this.getHeadquartersSuiteNumber(), other.getHeadquartersSuiteNumber())) { + return false; + } else if (!Objects.equals(this.getHeadquartersZipCode(), other.getHeadquartersZipCode())) { + return false; + } + + return true; + } + + @Override + public String getHeadquartersCity () { + return this.headquartersCity; + } + + @Override + public void setHeadquartersCity (final String headquartersCity) { + this.headquartersCity = headquartersCity; + } + + @Override + public Country getHeadquartersCountry () { + return this.headquartersCountry; + } + + @Override + public void setHeadquartersCountry (final Country headquartersCountry) { + this.headquartersCountry = headquartersCountry; + } + + @Override + @SuppressWarnings ("ReturnOfDateField") + public Calendar getHeadquartersCreated () { + return this.headquartersCreated; + } + + @Override + @SuppressWarnings ("AssignmentToDateFieldFromParameter") + public void setHeadquartersCreated (final Calendar headquartersCreated) { + this.headquartersCreated = headquartersCreated; + } + + @Override + public DialableFaxNumber getHeadquartersFaxNumber () { + return this.headquartersFaxNumber; + } + + @Override + public void setHeadquartersFaxNumber (final DialableFaxNumber headquartersFaxNumber) { + this.headquartersFaxNumber = headquartersFaxNumber; + } + + @Override + public Short getHeadquartersHouseNumber () { + return this.headquartersHouseNumber; + } + + @Override + public void setHeadquartersHouseNumber (final Short headquartersHouseNumber) { + this.headquartersHouseNumber = headquartersHouseNumber; + } + + @Override + public Long getHeadquartersId () { + return this.headquartersId; + } + + @Override + public void setHeadquartersId (final Long headquartersId) { + this.headquartersId = headquartersId; + } + + @Override + public DialableLandLineNumber getHeadquartersPhoneNumber () { + return this.headquartersPhoneNumber; + } + + @Override + public void setHeadquartersPhoneNumber (final DialableLandLineNumber headquartersPhoneNumber) { + this.headquartersPhoneNumber = headquartersPhoneNumber; + } + + @Override + public Short getHeadquartersStore () { + return this.headquartersStore; + } + + @Override + public void setHeadquartersStore (final Short headquartersStore) { + this.headquartersStore = headquartersStore; + } + + @Override + public String getHeadquartersStreet () { + return this.headquartersStreet; + } + + @Override + public void setHeadquartersStreet (final String headquartersStreet) { + this.headquartersStreet = headquartersStreet; + } + + @Override + public Short getHeadquartersSuiteNumber () { + return this.headquartersSuiteNumber; + } + + @Override + public void setHeadquartersSuiteNumber (final Short headquartersSuiteNumber) { + this.headquartersSuiteNumber = headquartersSuiteNumber; + } + + @Override + public User getHeadquartersUserOwner () { + return this.headquartersUserOwner; + } + + @Override + public void setHeadquartersUserOwner (final User headquartersUserOwner) { + this.headquartersUserOwner = headquartersUserOwner; + } + + @Override + public Integer getHeadquartersZipCode () { + return this.headquartersZipCode; + } + + @Override + public void setHeadquartersZipCode (final Integer headquartersZipCode) { + this.headquartersZipCode = headquartersZipCode; + } + + @Override + public int hashCode () { + int hash = 7; + + hash = 47 * hash + Objects.hashCode(this.getHeadquartersId()); + hash = 47 * hash + Objects.hashCode(this.getHeadquartersCity()); + hash = 47 * hash + Objects.hashCode(this.getHeadquartersCountry()); + hash = 47 * hash + Objects.hashCode(this.getHeadquartersHouseNumber()); + hash = 47 * hash + Objects.hashCode(this.getHeadquartersStore()); + hash = 47 * hash + Objects.hashCode(this.getHeadquartersStreet()); + hash = 47 * hash + Objects.hashCode(this.getHeadquartersSuiteNumber()); + hash = 47 * hash + Objects.hashCode(this.getHeadquartersZipCode()); + + return hash; + } + +} diff --git a/src/org/mxchange/jcontactsbusiness/headquarters/HeadQuartersData.java b/src/org/mxchange/jcontactsbusiness/headquarters/HeadQuartersData.java deleted file mode 100644 index 3ca4eaf..0000000 --- a/src/org/mxchange/jcontactsbusiness/headquarters/HeadQuartersData.java +++ /dev/null @@ -1,206 +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 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jcontactsbusiness.headquarters; - -import java.io.Serializable; -import java.util.Calendar; -import org.mxchange.jcountry.data.Country; -import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber; -import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber; -import org.mxchange.jusercore.model.user.User; - -/** - * A POJI for headquarters data - *

- * @author Roland Häder - */ -public interface HeadQuartersData extends Serializable { - - /** - * Getter for headquarters' city name - *

- * @return Headquarters' city name - */ - String getHeadquartersCity (); - - /** - * Setter for headquarters' city name - *

- * @param headquartersCity Headquarters' city name - */ - void setHeadquartersCity (final String headquartersCity); - - /** - * Getter for headquarters' country code - *

- * @return Headquarters' country code - */ - Country getHeadquartersCountry (); - - /** - * Setter for headquarters' country code - *

- * @param headquartersCountryCode Headquarters' country code - */ - void setHeadquartersCountry (final Country headquartersCountryCode); - - /** - * Getter for headquarters' house number - *

- * @return Headquarters' house number - */ - Short getHeadquartersHouseNumber (); - - /** - * Setter for headquarters' house number - *

- * @param headquartersHouseNumber Headquarters' house number - */ - void setHeadquartersHouseNumber (final Short headquartersHouseNumber); - - /** - * Getter for headquarters' id number - *

- * @return Headquarters' id number - */ - Long getHeadquartersId (); - - /** - * Setter for headquarters' id number - *

- * @param headquartersId Headquarters' id number - */ - void setHeadquartersId (final Long headquartersId); - - /** - * Getter for headquarters' store number - *

- * @return Headquarters' store number - */ - Short getHeadquartersStore (); - - /** - * Setter for headquarters' store number - *

- * @param headquartersStore Headquarters' store number - */ - void setHeadquartersStore (final Short headquartersStore); - - /** - * Getter for headquarters' street name - *

- * @return Headquarters' street name - */ - String getHeadquartersStreet (); - - /** - * Setter for headquarters' street name - *

- * @param headquartersStreet Headquarters' street name - */ - void setHeadquartersStreet (final String headquartersStreet); - - /** - * Getter for headquarters' suite number - *

- * @return Headquarters' suite number - */ - Short getHeadquartersSuiteNumber (); - - /** - * Setter for headquarters' suite number - *

- * @param headquartersSuiteNumber Headquarters' suite number - */ - void setHeadquartersSuiteNumber (final Short headquartersSuiteNumber); - - /** - * Getter for headquarters' ZIP code - *

- * @return Headquarters' ZIP code - */ - Integer getHeadquartersZipCode (); - - /** - * Setter for headquarters' ZIP code - *

- * @param headquartersZipCode Headquarters' ZIP code - */ - void setHeadquartersZipCode (final Integer headquartersZipCode); - - /** - * Getter for headquarters' phone number - *

- * @return Headquarters' phone number - */ - DialableLandLineNumber getHeadquartersPhoneNumber (); - - /** - * Setter for headquarters' phone number - *

- * @param headquartersPhoneNumber Headquarters' phone number - */ - void setHeadquartersPhoneNumber (final DialableLandLineNumber headquartersPhoneNumber); - - /** - * Getter for headquarters' fax number - *

- * @return Headquarters' fax number - */ - DialableFaxNumber getHeadquartersFaxNumber (); - - /** - * Setter for headquarters' fax number - *

- * @param headquartersFaxNumber Headquarters' fax number - */ - void setHeadquartersFaxNumber (final DialableFaxNumber headquartersFaxNumber); - - /** - * Getter for user owner instance - *

- * @return User owner instance - */ - User getHeadquartersUserOwner (); - - /** - * Setter for user owner instance - *

- * @param headquartersUserOwner User owner instance - */ - void setHeadquartersUserOwner (final User headquartersUserOwner); - - /** - * Getter for timestamp when this entry has been created - *

- * @return Timestamp when this entry has been created - */ - Calendar getHeadquartersCreated (); - - /** - * Setter for timestamp when this entry has been created - *

- * @param headquartersCreated Timestamp when this entry has been created - */ - void setHeadquartersCreated (final Calendar headquartersCreated); - - @Override - boolean equals (final Object object); - - @Override - int hashCode (); -} diff --git a/src/org/mxchange/jcontactsbusiness/headquarters/HeadquartersData.java b/src/org/mxchange/jcontactsbusiness/headquarters/HeadquartersData.java new file mode 100644 index 0000000..598fe3d --- /dev/null +++ b/src/org/mxchange/jcontactsbusiness/headquarters/HeadquartersData.java @@ -0,0 +1,206 @@ +/* + * 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 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.jcontactsbusiness.headquarters; + +import java.io.Serializable; +import java.util.Calendar; +import org.mxchange.jcountry.data.Country; +import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber; +import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber; +import org.mxchange.jusercore.model.user.User; + +/** + * A POJI for headquarters data + *

+ * @author Roland Häder + */ +public interface HeadquartersData extends Serializable { + + /** + * Getter for headquarters' city name + *

+ * @return Headquarters' city name + */ + String getHeadquartersCity (); + + /** + * Setter for headquarters' city name + *

+ * @param headquartersCity Headquarters' city name + */ + void setHeadquartersCity (final String headquartersCity); + + /** + * Getter for headquarters' country code + *

+ * @return Headquarters' country code + */ + Country getHeadquartersCountry (); + + /** + * Setter for headquarters' country code + *

+ * @param headquartersCountryCode Headquarters' country code + */ + void setHeadquartersCountry (final Country headquartersCountryCode); + + /** + * Getter for headquarters' house number + *

+ * @return Headquarters' house number + */ + Short getHeadquartersHouseNumber (); + + /** + * Setter for headquarters' house number + *

+ * @param headquartersHouseNumber Headquarters' house number + */ + void setHeadquartersHouseNumber (final Short headquartersHouseNumber); + + /** + * Getter for headquarters' id number + *

+ * @return Headquarters' id number + */ + Long getHeadquartersId (); + + /** + * Setter for headquarters' id number + *

+ * @param headquartersId Headquarters' id number + */ + void setHeadquartersId (final Long headquartersId); + + /** + * Getter for headquarters' store number + *

+ * @return Headquarters' store number + */ + Short getHeadquartersStore (); + + /** + * Setter for headquarters' store number + *

+ * @param headquartersStore Headquarters' store number + */ + void setHeadquartersStore (final Short headquartersStore); + + /** + * Getter for headquarters' street name + *

+ * @return Headquarters' street name + */ + String getHeadquartersStreet (); + + /** + * Setter for headquarters' street name + *

+ * @param headquartersStreet Headquarters' street name + */ + void setHeadquartersStreet (final String headquartersStreet); + + /** + * Getter for headquarters' suite number + *

+ * @return Headquarters' suite number + */ + Short getHeadquartersSuiteNumber (); + + /** + * Setter for headquarters' suite number + *

+ * @param headquartersSuiteNumber Headquarters' suite number + */ + void setHeadquartersSuiteNumber (final Short headquartersSuiteNumber); + + /** + * Getter for headquarters' ZIP code + *

+ * @return Headquarters' ZIP code + */ + Integer getHeadquartersZipCode (); + + /** + * Setter for headquarters' ZIP code + *

+ * @param headquartersZipCode Headquarters' ZIP code + */ + void setHeadquartersZipCode (final Integer headquartersZipCode); + + /** + * Getter for headquarters' phone number + *

+ * @return Headquarters' phone number + */ + DialableLandLineNumber getHeadquartersPhoneNumber (); + + /** + * Setter for headquarters' phone number + *

+ * @param headquartersPhoneNumber Headquarters' phone number + */ + void setHeadquartersPhoneNumber (final DialableLandLineNumber headquartersPhoneNumber); + + /** + * Getter for headquarters' fax number + *

+ * @return Headquarters' fax number + */ + DialableFaxNumber getHeadquartersFaxNumber (); + + /** + * Setter for headquarters' fax number + *

+ * @param headquartersFaxNumber Headquarters' fax number + */ + void setHeadquartersFaxNumber (final DialableFaxNumber headquartersFaxNumber); + + /** + * Getter for user owner instance + *

+ * @return User owner instance + */ + User getHeadquartersUserOwner (); + + /** + * Setter for user owner instance + *

+ * @param headquartersUserOwner User owner instance + */ + void setHeadquartersUserOwner (final User headquartersUserOwner); + + /** + * Getter for timestamp when this entry has been created + *

+ * @return Timestamp when this entry has been created + */ + Calendar getHeadquartersCreated (); + + /** + * Setter for timestamp when this entry has been created + *

+ * @param headquartersCreated Timestamp when this entry has been created + */ + void setHeadquartersCreated (final Calendar headquartersCreated); + + @Override + boolean equals (final Object object); + + @Override + int hashCode (); +}