]> git.mxchange.org Git - jcontacts-business-core.git/blob - src/org/mxchange/jcontactsbusiness/department/CompanyDepartment.java
ignored create-persistence-unit warning as no persistence.xml shall be created here...
[jcontacts-business-core.git] / src / org / mxchange / jcontactsbusiness / department / CompanyDepartment.java
1 /*
2  * Copyright (C) 2016 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 java.util.Calendar;
20 import java.util.Objects;
21 import javax.persistence.Basic;
22 import javax.persistence.CascadeType;
23 import javax.persistence.Column;
24 import javax.persistence.Entity;
25 import javax.persistence.GeneratedValue;
26 import javax.persistence.GenerationType;
27 import javax.persistence.Id;
28 import javax.persistence.JoinColumn;
29 import javax.persistence.ManyToOne;
30 import javax.persistence.OneToOne;
31 import javax.persistence.Table;
32 import javax.persistence.Temporal;
33 import javax.persistence.TemporalType;
34 import org.mxchange.jcontactsbusiness.BusinessContact;
35 import org.mxchange.jcontactsbusiness.CompanyContact;
36 import org.mxchange.jcontactsbusiness.branch.BranchOffice;
37 import org.mxchange.jcontactsbusiness.branch.CompanyBranchOffice;
38 import org.mxchange.jcontactsbusiness.employee.CompanyEmployee;
39 import org.mxchange.jcontactsbusiness.employee.Employee;
40 import org.mxchange.jcontactsbusiness.headquarters.CompanyHeadQuartersData;
41 import org.mxchange.jcontactsbusiness.headquarters.HeadQuartersData;
42 import org.mxchange.jusercore.model.user.LoginUser;
43 import org.mxchange.jusercore.model.user.User;
44
45 /**
46  * A POJO for company departments
47  * <p>
48  * @author Roland Haeder<roland@mxchange.org>
49  */
50 @Entity (name = "company_departments")
51 @Table (name = "company_departments")
52 @SuppressWarnings ("PersistenceUnitPresent")
53 public class CompanyDepartment implements Department {
54
55         /**
56          * Serial number
57          */
58         private static final long serialVersionUID = 94_835_918_958_717_660L;
59
60         /**
61          * Where this department is located
62          */
63         @JoinColumn (name = "department_headquarters_id")
64         @OneToOne (targetEntity = CompanyHeadQuartersData.class, cascade = CascadeType.ALL)
65         private HeadQuartersData departentHeadquarters;
66
67         /**
68          * Where this department is located
69          */
70         @JoinColumn (name = "department_branch_id")
71         @ManyToOne (targetEntity = CompanyBranchOffice.class, cascade = CascadeType.ALL)
72         private BranchOffice departmentBranchOffice;
73
74         /**
75          * Connection to company contact
76          */
77         @JoinColumn (name = "department_company_id", nullable = false, updatable = false)
78         @ManyToOne (targetEntity = CompanyContact.class, cascade = CascadeType.ALL, optional = false)
79         private BusinessContact departmentCompany;
80
81         /**
82          * Timestamp when this entry has been created
83          */
84         @Basic (optional = false)
85         @Temporal (TemporalType.TIMESTAMP)
86         @Column (name = "department_entry_created", nullable = false, updatable = false)
87         private Calendar departmentCreated;
88
89         /**
90          * Id number
91          */
92         @Id
93         @GeneratedValue (strategy = GenerationType.IDENTITY)
94         @Column (name = "department_id", nullable = false, updatable = false)
95         private Long departmentId;
96
97         /**
98          * Department lead employee
99          */
100         @JoinColumn (name = "department_lead_id", nullable = false)
101         @OneToOne (targetEntity = CompanyEmployee.class, cascade = CascadeType.ALL)
102         private Employee departmentLead;
103
104         /**
105          * Department name
106          */
107         @Basic (optional = false)
108         @Column (name = "department_name", length = 100, nullable = false)
109         private String departmentName;
110
111         /**
112          * User owner instance
113          */
114         @JoinColumn (name = "department_user_id", nullable = false, updatable = false)
115         @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.REFRESH, optional = false)
116         private User departmentUserOwner;
117
118         @Override
119         public boolean equals (final Object object) {
120                 if (null == object) {
121                         return false;
122                 } else if (this.getClass() != object.getClass()) {
123                         return false;
124                 }
125
126                 final Department other = (Department) object;
127
128                 if (!Objects.equals(this.getDepartmentCompany(), other.getDepartmentCompany())) {
129                         return false;
130                 } else if (!Objects.equals(this.getDepartmentName(), other.getDepartmentName())) {
131                         return false;
132                 }
133
134                 return true;
135         }
136
137         @Override
138         public int hashCode () {
139                 int hash = 5;
140                 hash = 53 * hash + Objects.hashCode(this.getDepartmentCompany());
141                 hash = 53 * hash + Objects.hashCode(this.getDepartmentName());
142                 return hash;
143         }
144
145         @Override
146         public HeadQuartersData getDepartentHeadquarters () {
147                 return this.departentHeadquarters;
148         }
149
150         @Override
151         public void setDepartentHeadquarters (final HeadQuartersData departentHeadquarters) {
152                 this.departentHeadquarters = departentHeadquarters;
153         }
154
155         @Override
156         public BranchOffice getDepartmentBranchOffice () {
157                 return this.departmentBranchOffice;
158         }
159
160         @Override
161         public void setDepartmentBranchOffice (final BranchOffice departmentBranchOffice) {
162                 this.departmentBranchOffice = departmentBranchOffice;
163         }
164
165         @Override
166         public BusinessContact getDepartmentCompany () {
167                 return this.departmentCompany;
168         }
169
170         @Override
171         public void setDepartmentCompany (final BusinessContact departmentCompany) {
172                 this.departmentCompany = departmentCompany;
173         }
174
175         @Override
176         public Calendar getDepartmentCreated () {
177                 return this.departmentCreated;
178         }
179
180         @Override
181         public void setDepartmentCreated (final Calendar departmentCreated) {
182                 this.departmentCreated = departmentCreated;
183         }
184
185         @Override
186         public Long getDepartmentId () {
187                 return this.departmentId;
188         }
189
190         @Override
191         public void setDepartmentId (final Long departmentId) {
192                 this.departmentId = departmentId;
193         }
194
195         @Override
196         public Employee getDepartmentLead () {
197                 return this.departmentLead;
198         }
199
200         @Override
201         public void setDepartmentLead (final Employee departmentLead) {
202                 this.departmentLead = departmentLead;
203         }
204
205         @Override
206         public String getDepartmentName () {
207                 return this.departmentName;
208         }
209
210         @Override
211         public void setDepartmentName (final String departmentName) {
212                 this.departmentName = departmentName;
213         }
214
215         @Override
216         public User getDepartmentUserOwner () {
217                 return this.departmentUserOwner;
218         }
219
220         @Override
221         public void setDepartmentUserOwner (final User departmentUserOwner) {
222                 this.departmentUserOwner = departmentUserOwner;
223         }
224
225 }