]> git.mxchange.org Git - jcontacts-business-core.git/blob - src/org/mxchange/jcontactsbusiness/branchoffice/CompanyBranchOffice.java
Continued:
[jcontacts-business-core.git] / src / org / mxchange / jcontactsbusiness / branchoffice / CompanyBranchOffice.java
1 /*
2  * Copyright (C) 2016, 2017 Roland Häder
3  *
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.
8  *
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.
13  *
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/>.
16  */
17 package org.mxchange.jcontactsbusiness.branchoffice;
18
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;
48
49 /**
50  * A POJO for company branch offices
51  * <p>
52  * @author Roland Häder<roland@mxchange.org>
53  */
54 @Entity (name = "company_branch_offices")
55 @Table (name = "company_branch_offices")
56 @NamedQueries ({
57         @NamedQuery (name = "AllBranchOffices", query = "SELECT bo FROM company_branch_offices AS bo ORDER BY bo.branchId ASC")
58 })
59 @SuppressWarnings ("PersistenceUnitPresent")
60 public class CompanyBranchOffice implements BranchOffice {
61
62         /**
63          * Serial number
64          */
65         @Transient
66         private static final long serialVersionUID = 47_957_817_276_871_852L;
67
68         /**
69          * Branch office's city name
70          */
71         @Basic (optional = false)
72         @Column (name = "branch_city", length = 100, nullable = false)
73         private String branchCity;
74
75         /**
76          * Company that has this branch office
77          */
78         @JoinColumn (name = "branch_company_id", nullable = false, updatable = false)
79         @OneToOne (targetEntity = CompanyBasicData.class, optional = false, cascade = CascadeType.ALL)
80         private BusinessBasicData branchCompany;
81
82         /**
83          * Branch office's country code
84          */
85         @JoinColumn (name = "branch_country_id", nullable = false)
86         @OneToOne (targetEntity = CountryData.class, cascade = CascadeType.REFRESH, optional = false)
87         private Country branchCountry;
88
89         /**
90          * Timestamp when this entry has been created
91          */
92         @Basic (optional = false)
93         @Temporal (TemporalType.TIMESTAMP)
94         @Column (name = "branch_entry_created", nullable = false, updatable = false)
95         private Calendar branchCreated;
96
97         /**
98          * Branch office's main email address (example: branch-name@company.com)
99          */
100         @Column (name = "branch_email_address", length = 100)
101         private String branchEmailAddress;
102
103         /**
104          * Reference to contact person
105          */
106         @JoinColumn (name = "branch_contact_employee_id")
107         @OneToOne (targetEntity = CompanyEmployee.class, cascade = CascadeType.ALL)
108         private Employee branchContactEmployee;
109
110         /**
111          * Branch office's main fax number: +ccxxxxxxxxxx
112          */
113         @JoinColumn (name = "branch_fax_number_id")
114         @OneToOne (targetEntity = FaxNumber.class, cascade = CascadeType.ALL)
115         private DialableFaxNumber branchFaxNumber;
116
117         /**
118          * Branch office's house number
119          */
120         @Basic (optional = false)
121         @Column (name = "branch_house_number", length = 3, nullable = false)
122         private Short branchHouseNumber;
123
124         /**
125          * Id number
126          */
127         @Id
128         @GeneratedValue (strategy = GenerationType.IDENTITY)
129         @Column (name = "branch_id", nullable = false, updatable = false)
130         private Long branchId;
131
132         /**
133          * Branch office's main phone number: +ccxxxxxxxxxx
134          */
135         @JoinColumn (name = "branch_phone_number_id")
136         @OneToOne (targetEntity = LandLineNumber.class, cascade = CascadeType.ALL)
137         private DialableLandLineNumber branchPhoneNumber;
138
139         /**
140          * Branch office's store (if multiple-store building)
141          */
142         @Column (name = "branch_store", length = 3)
143         private Short branchStore;
144
145         /**
146          * Branch office's street name
147          */
148         @Basic (optional = false)
149         @Column (name = "branch_street", length = 100, nullable = false)
150         private String branchStreet;
151
152         /**
153          * Branch office's suite number (if applyable)
154          */
155         @Column (name = "branch_suite_number", length = 4)
156         private Short branchSuiteNumber;
157
158         /**
159          * User owner instance
160          */
161         @JoinColumn (name = "branch_user_id")
162         @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.REFRESH)
163         private User branchUserOwner;
164
165         /**
166          * Branch office's ZIP code
167          */
168         @Basic (optional = false)
169         @Column (name = "branch_zip_code", length = 6, nullable = false)
170         private Integer branchZipCode;
171
172         @Override
173         public boolean equals (final Object object) {
174                 if (null == object) {
175                         return false;
176                 } else if (this.getClass() != object.getClass()) {
177                         return false;
178                 }
179
180                 final BranchOffice other = (BranchOffice) object;
181
182                 if (!Objects.equals(this.getBranchId(), other.getBranchId())) {
183                         return false;
184                 } else if (!Objects.equals(this.getBranchCity(), other.getBranchCity())) {
185                         return false;
186                 } else if (!Objects.equals(this.getBranchCountry(), other.getBranchCountry())) {
187                         return false;
188                 } else if (!Objects.equals(this.getBranchHouseNumber(), other.getBranchHouseNumber())) {
189                         return false;
190                 } else if (!Objects.equals(this.getBranchStore(), other.getBranchStore())) {
191                         return false;
192                 } else if (!Objects.equals(this.getBranchStreet(), other.getBranchStreet())) {
193                         return false;
194                 } else if (!Objects.equals(this.getBranchSuiteNumber(), other.getBranchSuiteNumber())) {
195                         return false;
196                 } else if (!Objects.equals(this.getBranchZipCode(), other.getBranchZipCode())) {
197                         return false;
198                 }
199
200                 return true;
201         }
202
203         @Override
204         public String getBranchCity () {
205                 return this.branchCity;
206         }
207
208         @Override
209         public void setBranchCity (final String branchCity) {
210                 this.branchCity = branchCity;
211         }
212
213         @Override
214         public BusinessBasicData getBranchCompany () {
215                 return this.branchCompany;
216         }
217
218         @Override
219         public void setBranchCompany (final BusinessBasicData branchCompany) {
220                 this.branchCompany = branchCompany;
221         }
222
223         @Override
224         public Country getBranchCountry () {
225                 return this.branchCountry;
226         }
227
228         @Override
229         public void setBranchCountry (final Country branchCountry) {
230                 this.branchCountry = branchCountry;
231         }
232
233         @Override
234         @SuppressWarnings ("ReturnOfDateField")
235         public Calendar getBranchCreated () {
236                 return this.branchCreated;
237         }
238
239         @Override
240         @SuppressWarnings ("AssignmentToDateFieldFromParameter")
241         public void setBranchCreated (final Calendar branchCreated) {
242                 this.branchCreated = branchCreated;
243         }
244
245         @Override
246         public String getBranchEmailAddress () {
247                 return this.branchEmailAddress;
248         }
249
250         @Override
251         public void setBranchEmailAddress (final String branchEmailAddress) {
252                 this.branchEmailAddress = branchEmailAddress;
253         }
254
255         @Override
256         public Employee getBranchContactEmployee () {
257                 return this.branchContactEmployee;
258         }
259
260         @Override
261         public void setBranchContactEmployee (final Employee branchContactEmployee) {
262                 this.branchContactEmployee = branchContactEmployee;
263         }
264
265         @Override
266         public DialableFaxNumber getBranchFaxNumber () {
267                 return this.branchFaxNumber;
268         }
269
270         @Override
271         public void setBranchFaxNumber (final DialableFaxNumber branchFaxNumber) {
272                 this.branchFaxNumber = branchFaxNumber;
273         }
274
275         @Override
276         public Short getBranchHouseNumber () {
277                 return this.branchHouseNumber;
278         }
279
280         @Override
281         public void setBranchHouseNumber (final Short branchHouseNumber) {
282                 this.branchHouseNumber = branchHouseNumber;
283         }
284
285         @Override
286         public Long getBranchId () {
287                 return this.branchId;
288         }
289
290         @Override
291         public void setBranchId (final Long branchId) {
292                 this.branchId = branchId;
293         }
294
295         @Override
296         public DialableLandLineNumber getBranchPhoneNumber () {
297                 return this.branchPhoneNumber;
298         }
299
300         @Override
301         public void setBranchPhoneNumber (final DialableLandLineNumber branchPhoneNumber) {
302                 this.branchPhoneNumber = branchPhoneNumber;
303         }
304
305         @Override
306         public Short getBranchStore () {
307                 return this.branchStore;
308         }
309
310         @Override
311         public void setBranchStore (final Short branchStore) {
312                 this.branchStore = branchStore;
313         }
314
315         @Override
316         public String getBranchStreet () {
317                 return this.branchStreet;
318         }
319
320         @Override
321         public void setBranchStreet (final String branchStreet) {
322                 this.branchStreet = branchStreet;
323         }
324
325         @Override
326         public Short getBranchSuiteNumber () {
327                 return this.branchSuiteNumber;
328         }
329
330         @Override
331         public void setBranchSuiteNumber (final Short branchSuiteNumber) {
332                 this.branchSuiteNumber = branchSuiteNumber;
333         }
334
335         @Override
336         public User getBranchUserOwner () {
337                 return this.branchUserOwner;
338         }
339
340         @Override
341         public void setBranchUserOwner (final User branchUserOwner) {
342                 this.branchUserOwner = branchUserOwner;
343         }
344
345         @Override
346         public Integer getBranchZipCode () {
347                 return this.branchZipCode;
348         }
349
350         @Override
351         public void setBranchZipCode (final Integer branchZipCode) {
352                 this.branchZipCode = branchZipCode;
353         }
354
355         @Override
356         public int hashCode () {
357                 int hash = 7;
358
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());
367
368                 return hash;
369         }
370
371 }