2 * Copyright (C) 2015 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.employee;
19 import java.util.Objects;
20 import javax.persistence.CascadeType;
21 import javax.persistence.Column;
22 import javax.persistence.Entity;
23 import javax.persistence.FetchType;
24 import javax.persistence.GeneratedValue;
25 import javax.persistence.GenerationType;
26 import javax.persistence.Id;
27 import javax.persistence.JoinColumn;
28 import javax.persistence.OneToOne;
29 import javax.persistence.Table;
30 import org.mxchange.jcontacts.contact.Contact;
31 import org.mxchange.jcontacts.contact.UserContact;
32 import org.mxchange.jcontactsbusiness.BusinessContact;
33 import org.mxchange.jcontactsbusiness.CompanyContact;
34 import org.mxchange.jcontactsbusiness.branch.BranchOffice;
35 import org.mxchange.jcontactsbusiness.branch.CompanyBranchOffice;
36 import org.mxchange.jcontactsbusiness.department.CompanyDepartment;
37 import org.mxchange.jcontactsbusiness.department.Department;
38 import org.mxchange.jcontactsbusiness.jobposition.EmployeePosition;
39 import org.mxchange.jcontactsbusiness.jobposition.JobPosition;
40 import org.mxchange.jphone.phonenumbers.cellphone.CellphoneNumber;
41 import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber;
44 * A POJO for company employees (including CEO)
46 * @author Roland Haeder
48 @Entity (name = "company_employees")
49 @Table (name = "company_employees")
50 public class CompanyEmployee implements Employee, Comparable<Employee> {
55 private static final long serialVersionUID = 48_959_819_859_812_076L;
58 * Branch office the employee works at
60 @JoinColumn (name = "employee_branch_id")
61 @OneToOne (targetEntity = CompanyBranchOffice.class, cascade = CascadeType.ALL)
62 private BranchOffice employeeBranchOffice;
65 * Company the employee is working at
67 @JoinColumn (name = "employee_company_id", nullable = false, updatable = false)
68 @OneToOne (targetEntity = CompanyContact.class, cascade = CascadeType.ALL, optional = false)
69 private BusinessContact employeeCompany;
72 * Department the employee works at
74 @JoinColumn (name = "employee_department_id")
75 @OneToOne (targetEntity = CompanyDepartment.class, cascade = CascadeType.ALL)
76 private Department employeeDepartment;
79 * Employee's email address
81 @Column (name = "employee_email_address", length = 30)
82 private String employeeEmailAddress;
88 @Column (name = "employee_id", length = 20, nullable = false, updatable = false)
89 @GeneratedValue (strategy = GenerationType.IDENTITY)
90 private Long employeeId;
93 * Employee's business mobile number
95 @JoinColumn (name = "employee_mobile_number_id")
96 @OneToOne (targetEntity = CellphoneNumber.class, cascade = CascadeType.ALL)
97 private DialableCellphoneNumber employeeMobileNumber;
102 @Column (name = "employee_number", length = 20)
103 private String employeeNumber;
106 * Employee's personal data
108 @JoinColumn (name = "employee_personal_data_id", nullable = false, updatable = false)
109 @OneToOne (targetEntity = UserContact.class, cascade = CascadeType.ALL, optional = false, fetch = FetchType.EAGER)
110 private Contact employeePersonalData;
113 * Employee's phone extension (or number if different)
115 @Column (name = "employee_phone_extension", length = 10)
116 private Integer employeePhoneExtension;
119 * Employee's position (example: CEO)
121 @JoinColumn (name = "employee_position_id")
122 @OneToOne (targetEntity = EmployeePosition.class, cascade = CascadeType.ALL, fetch = FetchType.EAGER)
123 private JobPosition employeePosition;
126 public int compareTo (final Employee employee) {
127 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
131 public boolean equals (final Object object) {
132 if (object == null) {
134 } else if (getClass() != object.getClass()) {
138 final Employee other = (Employee) object;
140 if (!Objects.equals(this.getEmployeeCompany(), other.getEmployeeCompany())) {
142 } else if (!Objects.equals(this.getEmployeeNumber(), other.getEmployeeNumber())) {
144 } else if (!Objects.equals(this.getEmployeePersonalData(), other.getEmployeePersonalData())) {
152 public BranchOffice getEmployeeBranchOffice () {
153 return this.employeeBranchOffice;
157 public void setEmployeeBranchOffice (final BranchOffice employeeBranchOffice) {
158 this.employeeBranchOffice = employeeBranchOffice;
162 public BusinessContact getEmployeeCompany () {
163 return this.employeeCompany;
167 public void setEmployeeCompany (final BusinessContact employeeCompany) {
168 this.employeeCompany = employeeCompany;
172 public Department getEmployeeDepartment () {
173 return this.employeeDepartment;
177 public void setEmployeeDepartment (final Department employeeDepartment) {
178 this.employeeDepartment = employeeDepartment;
182 public String getEmployeeEmailAddress () {
183 return this.employeeEmailAddress;
187 public void setEmployeeEmailAddress (final String employeeEmailAddress) {
188 this.employeeEmailAddress = employeeEmailAddress;
192 public Long getEmployeeId () {
193 return this.employeeId;
197 public void setEmployeeId (final Long employeeId) {
198 this.employeeId = employeeId;
202 public DialableCellphoneNumber getEmployeeMobileNumber () {
203 return this.employeeMobileNumber;
207 public void setEmployeeMobileNumber (final DialableCellphoneNumber employeeMobileNumber) {
208 this.employeeMobileNumber = employeeMobileNumber;
212 public String getEmployeeNumber () {
213 return this.employeeNumber;
217 public void setEmployeeNumber (final String employeeNumber) {
218 this.employeeNumber = employeeNumber;
222 public Contact getEmployeePersonalData () {
223 return this.employeePersonalData;
227 public void setEmployeePersonalData (final Contact employeePersonalData) {
228 this.employeePersonalData = employeePersonalData;
232 public Integer getEmployeePhoneExtension () {
233 return this.employeePhoneExtension;
237 public void setEmployeePhoneExtension (final Integer employeePhoneExtension) {
238 this.employeePhoneExtension = employeePhoneExtension;
242 public JobPosition getEmployeePosition () {
243 return this.employeePosition;
247 public void setEmployeePosition (final JobPosition employeePosition) {
248 this.employeePosition = employeePosition;
252 public int hashCode () {
254 hash = 97 * hash + Objects.hashCode(this.getEmployeeCompany());
255 hash = 97 * hash + Objects.hashCode(this.getEmployeeNumber());
256 hash = 97 * hash + Objects.hashCode(this.getEmployeePersonalData());