2 * Copyright (C) 2016 Roland Haeder
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.branch;
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.FetchType;
26 import javax.persistence.GeneratedValue;
27 import javax.persistence.GenerationType;
28 import javax.persistence.Id;
29 import javax.persistence.JoinColumn;
30 import javax.persistence.OneToOne;
31 import javax.persistence.Table;
32 import javax.persistence.Temporal;
33 import javax.persistence.TemporalType;
34 import org.mxchange.jcontactsbusiness.CompanyContact;
35 import org.mxchange.jcountry.data.Country;
36 import org.mxchange.jcountry.data.CountryData;
37 import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
38 import org.mxchange.jphone.phonenumbers.fax.FaxNumber;
39 import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
40 import org.mxchange.jphone.phonenumbers.landline.LandLineNumber;
41 import org.mxchange.jusercore.model.user.LoginUser;
42 import org.mxchange.jusercore.model.user.User;
45 * A POJO for company branch offices
47 * @author Roland Haeder
49 @Entity (name = "company_branch_offices")
50 @Table (name = "company_branch_offices")
51 public class CompanyBranchOffice implements BranchOffice, Comparable<BranchOffice> {
56 private static final long serialVersionUID = 47_957_817_276_871_852L;
59 * Branch office's city name
61 @Basic (optional = false)
62 @Column (name = "branch_city", length = 100, nullable = false)
63 private String branchCity;
66 * Company that has this branch office
68 @JoinColumn (name = "branch_company_id", nullable = false, updatable = false)
69 @OneToOne (targetEntity = CompanyContact.class, optional = false, cascade = CascadeType.ALL)
70 private Long branchCompanyContact;
73 * Branch office's country code
75 @JoinColumn (name = "branch_country_id", nullable = false)
76 @OneToOne (targetEntity = CountryData.class, cascade = CascadeType.MERGE, optional = false, fetch = FetchType.EAGER)
77 private Country branchCountry;
80 * Branch office's main email address (example: branch-name@company.com)
82 @Column (name = "branch_email_address", length = 100)
83 private String branchEmailAddress;
86 * Branch office's main fax number: +ccxxxxxxxxxx
88 @JoinColumn (name = "branch_fax_number_id")
89 @OneToOne (targetEntity = FaxNumber.class, cascade = CascadeType.ALL)
90 private DialableFaxNumber branchFaxNumber;
93 * Branch office's house number
95 @Basic (optional = false)
96 @Column (name = "branch_house_number", length = 3, nullable = false)
97 private Short branchHouseNumber;
103 @GeneratedValue (strategy = GenerationType.IDENTITY)
104 @Column (name = "branch_id", length = 20, nullable = false, updatable = false)
105 private Long branchId;
108 * Branch office's main phone number: +ccxxxxxxxxxx
110 @JoinColumn (name = "branch_phone_number_id")
111 @OneToOne (targetEntity = LandLineNumber.class, cascade = CascadeType.ALL)
112 private DialableLandLineNumber branchPhoneNumber;
115 * Branch office's store (if multiple-store building)
117 @Column (name = "branch_store", length = 3)
118 private Short branchStore;
121 * Branch office's street name
123 @Basic (optional = false)
124 @Column (name = "branch_street", length = 100, nullable = false)
125 private String branchStreet;
128 * Branch office's suite number (if applyable)
130 @Column (name = "branch_suite_number", length = 4)
131 private Short branchSuiteNumber;
134 * Branch office's ZIP code
136 @Basic (optional = false)
137 @Column (name = "branch_zip_code", length = 6, nullable = false)
138 private Integer branchZipCode;
141 * User owner instance
143 @JoinColumn (name = "branch_user_id", nullable = false, updatable = false)
144 @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.MERGE, optional = false)
145 private User branchUserOwner;
148 * Timestamp when this entry has been created
150 @Basic (optional = false)
151 @Temporal (TemporalType.TIMESTAMP)
152 @Column (name = "branch_entry_created", nullable = false, updatable = false)
153 private Calendar branchCreated;
156 public String getBranchCity () {
157 return this.branchCity;
161 public void setBranchCity (final String branchCity) {
162 this.branchCity = branchCity;
166 public Long getBranchCompanyContact () {
167 return this.branchCompanyContact;
171 public void setBranchCompanyContact (final Long branchCompanyContact) {
172 this.branchCompanyContact = branchCompanyContact;
176 public Country getBranchCountry () {
177 return this.branchCountry;
181 public void setBranchCountry (final Country branchCountry) {
182 this.branchCountry = branchCountry;
186 public String getBranchEmailAddress () {
187 return this.branchEmailAddress;
191 public void setBranchEmailAddress (final String branchEmailAddress) {
192 this.branchEmailAddress = branchEmailAddress;
196 public DialableFaxNumber getBranchFaxNumber () {
197 return this.branchFaxNumber;
201 public void setBranchFaxNumber (final DialableFaxNumber branchFaxNumber) {
202 this.branchFaxNumber = branchFaxNumber;
206 public Short getBranchHouseNumber () {
207 return this.branchHouseNumber;
211 public void setBranchHouseNumber (final Short branchHouseNumber) {
212 this.branchHouseNumber = branchHouseNumber;
216 public Long getBranchId () {
217 return this.branchId;
221 public void setBranchId (final Long branchId) {
222 this.branchId = branchId;
226 public DialableLandLineNumber getBranchPhoneNumber () {
227 return this.branchPhoneNumber;
231 public void setBranchPhoneNumber (final DialableLandLineNumber branchPhoneNumber) {
232 this.branchPhoneNumber = branchPhoneNumber;
236 public Short getBranchStore () {
237 return this.branchStore;
241 public void setBranchStore (final Short branchStore) {
242 this.branchStore = branchStore;
246 public String getBranchStreet () {
247 return this.branchStreet;
251 public void setBranchStreet (final String branchStreet) {
252 this.branchStreet = branchStreet;
256 public Short getBranchSuiteNumber () {
257 return this.branchSuiteNumber;
261 public void setBranchSuiteNumber (final Short branchSuiteNumber) {
262 this.branchSuiteNumber = branchSuiteNumber;
266 public Integer getBranchZipCode () {
267 return this.branchZipCode;
271 public void setBranchZipCode (final Integer branchZipCode) {
272 this.branchZipCode = branchZipCode;
276 public Calendar getBranchCreated () {
277 return this.branchCreated;
281 public void setBranchCreated (final Calendar branchCreated) {
282 this.branchCreated = branchCreated;
286 public User getBranchUserOwner () {
287 return this.branchUserOwner;
291 public void setBranchUserOwner (final User branchUserOwner) {
292 this.branchUserOwner = branchUserOwner;
296 public int compareTo (final BranchOffice branchOffice) {
297 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
301 public boolean equals (final Object object) {
302 if (object == null) {
304 } else if (getClass() != object.getClass()) {
308 final BranchOffice other = (BranchOffice) object;
310 if (!Objects.equals(this.getBranchCity(), other.getBranchCity())) {
312 } else if (!Objects.equals(this.getBranchCountry(), other.getBranchCountry())) {
314 } else if (!Objects.equals(this.getBranchHouseNumber(), other.getBranchHouseNumber())) {
316 } else if (!Objects.equals(this.getBranchStore(), other.getBranchStore())) {
318 } else if (!Objects.equals(this.getBranchStreet(), other.getBranchStreet())) {
320 } else if (!Objects.equals(this.getBranchSuiteNumber(), other.getBranchSuiteNumber())) {
322 } else if (!Objects.equals(this.getBranchZipCode(), other.getBranchZipCode())) {
330 public int hashCode () {
332 hash = 53 * hash + Objects.hashCode(this.getBranchCity());
333 hash = 53 * hash + Objects.hashCode(this.getBranchCountry());
334 hash = 53 * hash + Objects.hashCode(this.getBranchHouseNumber());
335 hash = 53 * hash + Objects.hashCode(this.getBranchStore());
336 hash = 53 * hash + Objects.hashCode(this.getBranchStreet());
337 hash = 53 * hash + Objects.hashCode(this.getBranchSuiteNumber());
338 hash = 53 * hash + Objects.hashCode(this.getBranchZipCode());