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