From: Roland Haeder Date: Sun, 11 Oct 2015 12:11:06 +0000 (+0200) Subject: added job position entity X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=d399d09ecd087dd705616f38631fe6cb5dfb1a74;p=jcontacts-business-core.git added job position entity --- diff --git a/src/org/mxchange/jcontactsbusiness/employee/CompanyEmployee.java b/src/org/mxchange/jcontactsbusiness/employee/CompanyEmployee.java index 31df0b1..c95c5c6 100644 --- a/src/org/mxchange/jcontactsbusiness/employee/CompanyEmployee.java +++ b/src/org/mxchange/jcontactsbusiness/employee/CompanyEmployee.java @@ -32,6 +32,8 @@ import org.mxchange.jcontactsbusiness.branch.BranchOffice; import org.mxchange.jcontactsbusiness.branch.CompanyBranchOffice; import org.mxchange.jcontactsbusiness.department.CompanyDepartment; import org.mxchange.jcontactsbusiness.department.Department; +import org.mxchange.jcontactsbusiness.jobposition.EmployeePosition; +import org.mxchange.jcontactsbusiness.jobposition.JobPosition; import org.mxchange.jphone.phonenumbers.cellphone.CellphoneNumber; import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber; @@ -107,9 +109,9 @@ public class CompanyEmployee implements Employee, Comparable { /** * Employee's position (example: CEO) */ - @Basic (optional = false) - @Column (name = "employee_status", length = 50, nullable = false) - private String employeePosition; + @JoinColumn (name = "employee_position_id", nullable = false) + @OneToOne (targetEntity = EmployeePosition.class, optional = false, cascade = CascadeType.ALL) + private JobPosition employeePosition; @Override public int compareTo (final Employee employee) { @@ -197,12 +199,12 @@ public class CompanyEmployee implements Employee, Comparable { } @Override - public String getEmployeePosition () { + public JobPosition getEmployeePosition () { return this.employeePosition; } @Override - public void setEmployeePosition (final String employeePosition) { + public void setEmployeePosition (final JobPosition employeePosition) { this.employeePosition = employeePosition; } } diff --git a/src/org/mxchange/jcontactsbusiness/employee/Employee.java b/src/org/mxchange/jcontactsbusiness/employee/Employee.java index 1c14cba..ea64f1e 100644 --- a/src/org/mxchange/jcontactsbusiness/employee/Employee.java +++ b/src/org/mxchange/jcontactsbusiness/employee/Employee.java @@ -20,6 +20,7 @@ import java.io.Serializable; import org.mxchange.jcontacts.contact.Contact; import org.mxchange.jcontactsbusiness.branch.BranchOffice; import org.mxchange.jcontactsbusiness.department.Department; +import org.mxchange.jcontactsbusiness.jobposition.JobPosition; import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber; /** @@ -146,12 +147,12 @@ public interface Employee extends Serializable { *

* @return Employee's position */ - public String getEmployeePosition (); + public JobPosition getEmployeePosition (); /** * Setter for employee's position *

* @param employeePosition Employee's position */ - public void setEmployeePosition (final String employeePosition); + public void setEmployeePosition (final JobPosition employeePosition); } diff --git a/src/org/mxchange/jcontactsbusiness/jobposition/EmployeePosition.java b/src/org/mxchange/jcontactsbusiness/jobposition/EmployeePosition.java new file mode 100644 index 0000000..68f2876 --- /dev/null +++ b/src/org/mxchange/jcontactsbusiness/jobposition/EmployeePosition.java @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2015 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.jcontactsbusiness.jobposition; + +import javax.persistence.Basic; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; + +/** + * A POJO for job positions + *

+ * @author Roland Haeder + */ +@Entity (name = "job_positions") +@Table (name = "job_positions") +public class EmployeePosition implements JobPosition, Comparable { + + /** + * Serial number + */ + private static final long serialVersionUID = 18_427_587_187_609L; + + /** + * Id number + */ + @Id + @GeneratedValue (strategy = GenerationType.IDENTITY) + @Column (name = "job_position_id", length = 20, nullable = false, updatable = false) + private Long jobPositionId; + + /** + * Name/description of the job position (example: CEO) + */ + @Basic (optional = false) + @Column (name = "job_position_name", length = 10, nullable = false, unique = true) + private String jobPositionName; + + @Override + public int compareTo (final JobPosition jobPosition) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public Long getJobPositionId () { + return this.jobPositionId; + } + + @Override + public void setJobPositionId (final Long jobPositionId) { + this.jobPositionId = jobPositionId; + } + + @Override + public String getJobPositionName () { + return this.jobPositionName; + } + + @Override + public void setJobPositionName (final String jobPositionName) { + this.jobPositionName = jobPositionName; + } + +} diff --git a/src/org/mxchange/jcontactsbusiness/jobposition/JobPosition.java b/src/org/mxchange/jcontactsbusiness/jobposition/JobPosition.java new file mode 100644 index 0000000..e9dc8f9 --- /dev/null +++ b/src/org/mxchange/jcontactsbusiness/jobposition/JobPosition.java @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2015 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.jcontactsbusiness.jobposition; + +import java.io.Serializable; + +/** + * A POJI for job positions + *

+ * @author Roland Haeder + */ +public interface JobPosition extends Serializable { + + /** + * Getter for id number + *

+ * @return Id number + */ + public Long getJobPositionId (); + + /** + * Setter for id number + *

+ * @param jobPositionId Id number + */ + public void setJobPositionId (final Long jobPositionId); + + /** + * Getter for job position name + *

+ * @return Job position name + */ + public String getJobPositionName (); + + /** + * Setter for job position name + *

+ * @param jobPositionName Job position name + */ + public void setJobPositionName (final String jobPositionName); +}