2 * Copyright (C) 2016, 2017 Roland Häder
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.jcontactsbusiness.branchoffice;
19 import java.util.Calendar;
20 import java.util.Objects;
21 import javax.persistence.Basic;
22 import javax.persistence.CascadeType;
23 import javax.persistence.Column;
24 import javax.persistence.Entity;
25 import javax.persistence.GeneratedValue;
26 import javax.persistence.GenerationType;
27 import javax.persistence.Id;
28 import javax.persistence.JoinColumn;
29 import javax.persistence.NamedQueries;
30 import javax.persistence.NamedQuery;
31 import javax.persistence.OneToOne;
32 import javax.persistence.Table;
33 import javax.persistence.Temporal;
34 import javax.persistence.TemporalType;
35 import javax.persistence.Transient;
36 import org.mxchange.jcontactsbusiness.basicdata.BusinessBasicData;
37 import org.mxchange.jcontactsbusiness.basicdata.CompanyBasicData;
38 import org.mxchange.jcontactsbusiness.employee.CompanyEmployee;
39 import org.mxchange.jcontactsbusiness.employee.Employee;
40 import org.mxchange.jcountry.data.Country;
41 import org.mxchange.jcountry.data.CountryData;
42 import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
43 import org.mxchange.jphone.phonenumbers.fax.FaxNumber;
44 import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
45 import org.mxchange.jphone.phonenumbers.landline.LandLineNumber;
46 import org.mxchange.jusercore.model.user.LoginUser;
47 import org.mxchange.jusercore.model.user.User;
50 * A POJO for company branch offices
52 * @author Roland Häder<roland@mxchange.org>
54 @Entity (name = "company_branch_offices")
55 @Table (name = "company_branch_offices")
57 @NamedQuery (name = "AllBranchOffices", query = "SELECT bo FROM company_branch_offices AS bo ORDER BY bo.branchId ASC")
59 @SuppressWarnings ("PersistenceUnitPresent")
60 public class CompanyBranchOffice implements BranchOffice {
66 private static final long serialVersionUID = 47_957_817_276_871_852L;
69 * Branch office's city name
71 @Basic (optional = false)
72 @Column (name = "branch_city", length = 100, nullable = false)
73 private String branchCity;
76 * Company that has this branch office
78 @JoinColumn (name = "branch_company_id", nullable = false, updatable = false)
79 @OneToOne (targetEntity = CompanyBasicData.class, optional = false, cascade = CascadeType.ALL)
80 private BusinessBasicData branchCompany;
83 * Branch office's country code
85 @JoinColumn (name = "branch_country_id", nullable = false)
86 @OneToOne (targetEntity = CountryData.class, cascade = CascadeType.REFRESH, optional = false)
87 private Country branchCountry;
90 * Timestamp when this entry has been created
92 @Basic (optional = false)
93 @Temporal (TemporalType.TIMESTAMP)
94 @Column (name = "branch_entry_created", nullable = false, updatable = false)
95 private Calendar branchCreated;
98 * Branch office's main email address (example: branch-name@company.com)
100 @Column (name = "branch_email_address", length = 100)
101 private String branchEmailAddress;
104 * Reference to contact person
106 @JoinColumn (name = "branch_contact_employee_id")
107 @OneToOne (targetEntity = CompanyEmployee.class, cascade = CascadeType.ALL)
108 private Employee branchContactEmployee;
111 * Branch office's main fax number: +ccxxxxxxxxxx
113 @JoinColumn (name = "branch_fax_number_id")
114 @OneToOne (targetEntity = FaxNumber.class, cascade = CascadeType.ALL)
115 private DialableFaxNumber branchFaxNumber;
118 * Branch office's house number
120 @Basic (optional = false)
121 @Column (name = "branch_house_number", length = 3, nullable = false)
122 private Short branchHouseNumber;
128 @GeneratedValue (strategy = GenerationType.IDENTITY)
129 @Column (name = "branch_id", nullable = false, updatable = false)
130 private Long branchId;
133 * Branch office's main phone number: +ccxxxxxxxxxx
135 @JoinColumn (name = "branch_phone_number_id")
136 @OneToOne (targetEntity = LandLineNumber.class, cascade = CascadeType.ALL)
137 private DialableLandLineNumber branchPhoneNumber;
140 * Branch office's store (if multiple-store building)
142 @Column (name = "branch_store", length = 3)
143 private Short branchStore;
146 * Branch office's street name
148 @Basic (optional = false)
149 @Column (name = "branch_street", length = 100, nullable = false)
150 private String branchStreet;
153 * Branch office's suite number (if applyable)
155 @Column (name = "branch_suite_number", length = 4)
156 private Short branchSuiteNumber;
159 * User owner instance
161 @JoinColumn (name = "branch_user_id")
162 @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.REFRESH)
163 private User branchUserOwner;
166 * Branch office's ZIP code
168 @Basic (optional = false)
169 @Column (name = "branch_zip_code", length = 6, nullable = false)
170 private Integer branchZipCode;
173 public boolean equals (final Object object) {
174 if (null == object) {
176 } else if (this.getClass() != object.getClass()) {
180 final BranchOffice other = (BranchOffice) object;
182 if (!Objects.equals(this.getBranchId(), other.getBranchId())) {
184 } else if (!Objects.equals(this.getBranchCity(), other.getBranchCity())) {
186 } else if (!Objects.equals(this.getBranchCountry(), other.getBranchCountry())) {
188 } else if (!Objects.equals(this.getBranchHouseNumber(), other.getBranchHouseNumber())) {
190 } else if (!Objects.equals(this.getBranchStore(), other.getBranchStore())) {
192 } else if (!Objects.equals(this.getBranchStreet(), other.getBranchStreet())) {
194 } else if (!Objects.equals(this.getBranchSuiteNumber(), other.getBranchSuiteNumber())) {
196 } else if (!Objects.equals(this.getBranchZipCode(), other.getBranchZipCode())) {
204 public String getBranchCity () {
205 return this.branchCity;
209 public void setBranchCity (final String branchCity) {
210 this.branchCity = branchCity;
214 public BusinessBasicData getBranchCompany () {
215 return this.branchCompany;
219 public void setBranchCompany (final BusinessBasicData branchCompany) {
220 this.branchCompany = branchCompany;
224 public Country getBranchCountry () {
225 return this.branchCountry;
229 public void setBranchCountry (final Country branchCountry) {
230 this.branchCountry = branchCountry;
234 @SuppressWarnings ("ReturnOfDateField")
235 public Calendar getBranchCreated () {
236 return this.branchCreated;
240 @SuppressWarnings ("AssignmentToDateFieldFromParameter")
241 public void setBranchCreated (final Calendar branchCreated) {
242 this.branchCreated = branchCreated;
246 public String getBranchEmailAddress () {
247 return this.branchEmailAddress;
251 public void setBranchEmailAddress (final String branchEmailAddress) {
252 this.branchEmailAddress = branchEmailAddress;
256 public Employee getBranchContactEmployee () {
257 return this.branchContactEmployee;
261 public void setBranchContactEmployee (final Employee branchContactEmployee) {
262 this.branchContactEmployee = branchContactEmployee;
266 public DialableFaxNumber getBranchFaxNumber () {
267 return this.branchFaxNumber;
271 public void setBranchFaxNumber (final DialableFaxNumber branchFaxNumber) {
272 this.branchFaxNumber = branchFaxNumber;
276 public Short getBranchHouseNumber () {
277 return this.branchHouseNumber;
281 public void setBranchHouseNumber (final Short branchHouseNumber) {
282 this.branchHouseNumber = branchHouseNumber;
286 public Long getBranchId () {
287 return this.branchId;
291 public void setBranchId (final Long branchId) {
292 this.branchId = branchId;
296 public DialableLandLineNumber getBranchPhoneNumber () {
297 return this.branchPhoneNumber;
301 public void setBranchPhoneNumber (final DialableLandLineNumber branchPhoneNumber) {
302 this.branchPhoneNumber = branchPhoneNumber;
306 public Short getBranchStore () {
307 return this.branchStore;
311 public void setBranchStore (final Short branchStore) {
312 this.branchStore = branchStore;
316 public String getBranchStreet () {
317 return this.branchStreet;
321 public void setBranchStreet (final String branchStreet) {
322 this.branchStreet = branchStreet;
326 public Short getBranchSuiteNumber () {
327 return this.branchSuiteNumber;
331 public void setBranchSuiteNumber (final Short branchSuiteNumber) {
332 this.branchSuiteNumber = branchSuiteNumber;
336 public User getBranchUserOwner () {
337 return this.branchUserOwner;
341 public void setBranchUserOwner (final User branchUserOwner) {
342 this.branchUserOwner = branchUserOwner;
346 public Integer getBranchZipCode () {
347 return this.branchZipCode;
351 public void setBranchZipCode (final Integer branchZipCode) {
352 this.branchZipCode = branchZipCode;
356 public int hashCode () {
359 hash = 53 * hash + Objects.hashCode(this.getBranchId());
360 hash = 53 * hash + Objects.hashCode(this.getBranchCity());
361 hash = 53 * hash + Objects.hashCode(this.getBranchCountry());
362 hash = 53 * hash + Objects.hashCode(this.getBranchHouseNumber());
363 hash = 53 * hash + Objects.hashCode(this.getBranchStore());
364 hash = 53 * hash + Objects.hashCode(this.getBranchStreet());
365 hash = 53 * hash + Objects.hashCode(this.getBranchSuiteNumber());
366 hash = 53 * hash + Objects.hashCode(this.getBranchZipCode());