]> git.mxchange.org Git - jcontacts-business-core.git/blob - src/org/mxchange/jcontactsbusiness/department/CompanyDepartment.java
8299bb45bd5baab1d777a35bf2f2ee5a4ff1bbfd
[jcontacts-business-core.git] / src / org / mxchange / jcontactsbusiness / department / CompanyDepartment.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.department;
18
19 import javax.persistence.Basic;
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.ManyToOne;
28 import javax.persistence.OneToOne;
29 import javax.persistence.Table;
30 import javax.persistence.Transient;
31 import org.mxchange.jcontactsbusiness.BusinessContact;
32 import org.mxchange.jcontactsbusiness.CompanyContact;
33 import org.mxchange.jcontactsbusiness.employee.CompanyEmployee;
34 import org.mxchange.jcontactsbusiness.employee.Employee;
35
36 /**
37  * A POJO for company departments
38  * <p>
39  * @author Roland Haeder
40  */
41 @Entity (name = "departments")
42 @Table (name = "departments")
43 public class CompanyDepartment implements Department, Comparable<Department> {
44
45         /**
46          * Serial number
47          */
48         private static final long serialVersionUID = 94_835_918_958_717_660L;
49
50         /**
51          * Connection to company contact
52          */
53         @JoinColumn (name = "department_company_id", nullable = false, updatable = false)
54         @ManyToOne (targetEntity = CompanyContact.class, cascade = CascadeType.ALL, optional = false)
55         @Transient
56         private BusinessContact departmentCompany;
57
58         /**
59          * Id number
60          */
61         @Id
62         @GeneratedValue (strategy = GenerationType.IDENTITY)
63         @Column (name = "department_id", length = 20, nullable = false, updatable = false)
64         private Long departmentId;
65
66         /**
67          * Department lead employee
68          */
69         @JoinColumn (name = "department_lead_id", nullable = false)
70         @OneToOne (targetEntity = CompanyEmployee.class, cascade = CascadeType.ALL)
71         @Transient
72         private Employee departmentLead;
73
74         /**
75          * Department name
76          */
77         @Basic (optional = false)
78         @Column (name = "department_name", length = 100, nullable = false)
79         private String departmentName;
80
81         @Override
82         public int compareTo (final Department department) {
83                 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
84         }
85
86         @Override
87         public BusinessContact getDepartmentCompany () {
88                 return this.departmentCompany;
89         }
90
91         @Override
92         public void setDepartmentCompany (final BusinessContact departmentCompany) {
93                 this.departmentCompany = departmentCompany;
94         }
95
96         @Override
97         public Long getDepartmentId () {
98                 return this.departmentId;
99         }
100
101         @Override
102         public void setDepartmentId (final Long departmentId) {
103                 this.departmentId = departmentId;
104         }
105
106         @Override
107         public Employee getDepartmentLead () {
108                 return this.departmentLead;
109         }
110
111         @Override
112         public void setDepartmentLead (final Employee departmentLead) {
113                 this.departmentLead = departmentLead;
114         }
115
116         @Override
117         public String getDepartmentName () {
118                 return this.departmentName;
119         }
120
121         @Override
122         public void setDepartmentName (final String departmentName) {
123                 this.departmentName = departmentName;
124         }
125 }