]> git.mxchange.org Git - jcontacts-business-core.git/blob - src/org/mxchange/jcontactsbusiness/CompanyContact.java
Continued:
[jcontacts-business-core.git] / src / org / mxchange / jcontactsbusiness / CompanyContact.java
1 /*
2  * Copyright (C) 2015 Roland Haeder
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;
18
19 import java.util.List;
20 import java.util.Objects;
21 import javax.persistence.CascadeType;
22 import javax.persistence.Column;
23 import javax.persistence.Entity;
24 import javax.persistence.GeneratedValue;
25 import javax.persistence.GenerationType;
26 import javax.persistence.Id;
27 import javax.persistence.JoinColumn;
28 import javax.persistence.OneToMany;
29 import javax.persistence.OneToOne;
30 import javax.persistence.Table;
31 import org.mxchange.jcontactsbusiness.basicdata.BusinessBasicData;
32 import org.mxchange.jcontactsbusiness.basicdata.CompanyBasicData;
33 import org.mxchange.jcontactsbusiness.branch.BranchOffice;
34 import org.mxchange.jcontactsbusiness.branch.CompanyBranchOffice;
35 import org.mxchange.jcontactsbusiness.employee.CompanyEmployee;
36 import org.mxchange.jcontactsbusiness.employee.Employee;
37 import org.mxchange.jcontactsbusiness.headquarters.CompanyHeadQuartersData;
38 import org.mxchange.jcontactsbusiness.headquarters.HeadQuartersData;
39
40 /**
41  * A POJO for business contacts
42  * <p>
43  * @author Roland Haeder
44  */
45 @Entity (name = "company_contacts")
46 @Table (name = "company_contacts")
47 public class CompanyContact implements BusinessContact, Comparable<BusinessContact> {
48
49         /**
50          * Serial number
51          */
52         private static final long serialVersionUID = 478_378_178_748_691L;
53
54         /**
55          * Reference to basic data
56          */
57         @JoinColumn (name = "company_basic_data_id", nullable = false, updatable = false)
58         @OneToOne (targetEntity = CompanyBasicData.class, cascade = CascadeType.ALL, optional = false)
59         private BusinessBasicData basicBusinessData;
60
61         /**
62          * Reference to employee branches
63          */
64         @JoinColumn (name = "company_branches_id", nullable = false, updatable = false)
65         @OneToMany (targetEntity = CompanyBranchOffice.class, cascade = CascadeType.ALL)
66         private List<BranchOffice> branches;
67
68         /**
69          * Reference to contact person
70          */
71         @JoinColumn (name = "company_contact_id")
72         @OneToOne (targetEntity = CompanyEmployee.class, cascade = CascadeType.ALL)
73         private Employee companyContact;
74
75         /**
76          * Id number
77          */
78         @Id
79         @Column (name = "company_id", length = 20, nullable = false, updatable = false)
80         @GeneratedValue (strategy = GenerationType.IDENTITY)
81         private Long companyContactId;
82
83         /**
84          * Reference to CEO "employee"
85          */
86         @JoinColumn (name = "company_founder_id")
87         @OneToOne (targetEntity = CompanyEmployee.class, cascade = CascadeType.ALL)
88         private Employee companyFounder;
89
90         /**
91          * Reference to employee list
92          */
93         @JoinColumn (name = "company_employees_id", nullable = false, updatable = false)
94         @OneToMany (targetEntity = CompanyEmployee.class, cascade = CascadeType.ALL)
95         private List<Employee> employees;
96
97         /**
98          * Reference to headquarters data
99          */
100         @JoinColumn (name = "company_headquarters_data_id", nullable = false, updatable = false)
101         @OneToOne (targetEntity = CompanyHeadQuartersData.class, cascade = CascadeType.ALL, optional = false)
102         private HeadQuartersData headQuartersData;
103
104         @Override
105         public int compareTo (final BusinessContact businessContact) {
106                 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
107         }
108
109         @Override
110         public boolean equals (final Object object) {
111                 if (object == null) {
112                         return false;
113                 } else if (getClass() != object.getClass()) {
114                         return false;
115                 }
116
117                 final BusinessContact other = (BusinessContact) object;
118
119                 return Objects.equals(this.getBasicBusinessData(), other.getBasicBusinessData());
120         }
121
122         @Override
123         public BusinessBasicData getBasicBusinessData () {
124                 return this.basicBusinessData;
125         }
126
127         @Override
128         public void setBasicBusinessData (final BusinessBasicData basicBusinessData) {
129                 this.basicBusinessData = basicBusinessData;
130         }
131
132         @Override
133         public List<BranchOffice> getBranches () {
134                 return this.branches;
135         }
136
137         @Override
138         public void setBranches (final List<BranchOffice> branches) {
139                 this.branches = branches;
140         }
141
142         @Override
143         public Employee getCompanyContact () {
144                 return this.companyContact;
145         }
146
147         @Override
148         public void setCompanyContact (final Employee companyContact) {
149                 this.companyContact = companyContact;
150         }
151
152         @Override
153         public Long getCompanyContactId () {
154                 return this.companyContactId;
155         }
156
157         @Override
158         public void setCompanyContactId (final Long companyContactId) {
159                 this.companyContactId = companyContactId;
160         }
161
162         @Override
163         public Employee getCompanyFounder () {
164                 return this.companyFounder;
165         }
166
167         @Override
168         public void setCompanyFounder (final Employee companyFounder) {
169                 this.companyFounder = companyFounder;
170         }
171
172         @Override
173         public List<Employee> getEmployees () {
174                 return this.employees;
175         }
176
177         @Override
178         public void setEmployees (final List<Employee> employees) {
179                 this.employees = employees;
180         }
181
182         @Override
183         public HeadQuartersData getHeadQuartersData () {
184                 return this.headQuartersData;
185         }
186
187         @Override
188         public void setHeadQuartersData (final HeadQuartersData headQuartersData) {
189                 this.headQuartersData = headQuartersData;
190         }
191
192         @Override
193         public int hashCode () {
194                 int hash = 3;
195                 hash = 37 * hash + Objects.hashCode(this.getBasicBusinessData());
196                 return hash;
197         }
198 }