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