2 * Copyright (C) 2016 - 2020 Free Software Foundation
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.jjobs.model.jobskill;
19 import java.util.Date;
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.OneToOne;
30 import javax.persistence.Table;
31 import javax.persistence.Temporal;
32 import javax.persistence.TemporalType;
33 import javax.persistence.Transient;
34 import org.mxchange.jcontactsbusiness.model.jobposition.EmployeePosition;
35 import org.mxchange.jcontactsbusiness.model.jobposition.HireableJobPosition;
36 import org.mxchange.jjobs.model.skill.JobSkill;
37 import org.mxchange.jjobs.model.skill.Skillable;
38 import org.mxchange.jusercore.model.user.LoginUser;
39 import org.mxchange.jusercore.model.user.User;
42 * A POJO entity for job position skills (linking job position and skill
45 * @author Roland Häder<roland@mxchange.org>
47 @Entity (name = "job_skills")
51 @SuppressWarnings ("PersistenceUnitPresent")
52 public class JobPositionSkill implements SkillableJobPosition {
58 private static final long serialVersionUID = 186_757_123_896_419L;
63 @JoinColumn (name = "skill_job_position_id", referencedColumnName = "job_position_id", updatable = false, nullable = false)
64 @OneToOne (cascade = CascadeType.ALL, targetEntity = EmployeePosition.class, optional = false)
65 private HireableJobPosition jobPosition;
68 * When this entry has been created
70 @Basic (optional = false)
71 @Column (name = "skill_job_created", nullable = false, updatable = false)
72 @Temporal (TemporalType.TIMESTAMP)
73 private Date jobPositionSkillCreated;
76 * Id number (primary key
79 @GeneratedValue (strategy = GenerationType.IDENTITY)
80 @Column (name = "skill_job_id", nullable = false, updatable = false)
81 private Long jobPositionSkillId;
84 * When this entry has been updated
86 @Column (name = "skill_job_updated", insertable = false)
87 @Temporal (TemporalType.TIMESTAMP)
88 private Date jobPositionSkillUpdated;
91 * Link to skill entity
93 @JoinColumn (name = "skill_job_skill_id", nullable = false, updatable = false, referencedColumnName = "skill_id")
94 @OneToOne (cascade = CascadeType.REFRESH, targetEntity = JobSkill.class)
95 private Skillable jobSkill;
98 * User added this skill (optional as administrators can add skills, too)
100 @JoinColumn (name = "skill_job_user_id", referencedColumnName = "user_id")
101 @OneToOne (cascade = CascadeType.REFRESH, targetEntity = LoginUser.class)
102 private User skillAddedUser;
105 * Skill importance (0=unimportant, 10=very important)
107 @Basic (optional = false)
108 @Column (name = "skill_job_importance", nullable = false)
109 private Short skillImportance;
112 * Default constructor, required for the JPA.
114 public JobPositionSkill () {
115 // Nothing to do here
119 * Constructor with all required entity properties
121 * @param jobPosition An instance of a HireableJobPosition class
122 * @param jobSkill An instance of a Skillable class
123 * @param skillImportance Importance level
125 public JobPositionSkill (final HireableJobPosition jobPosition, final Skillable jobSkill, final Short skillImportance) {
126 // Invoke default constructor
130 this.jobPosition = jobPosition;
131 this.jobSkill = jobSkill;
132 this.skillImportance = skillImportance;
136 public boolean equals (final Object object) {
137 if (this == object) {
139 } else if (null == object) {
141 } else if (this.getClass() != object.getClass()) {
145 final SkillableJobPosition jobPosition = (SkillableJobPosition) object;
147 if (!Objects.equals(this.getSkillImportance(), jobPosition.getSkillImportance())) {
149 } else if (!Objects.equals(this.getJobPosition(), jobPosition.getJobPosition())) {
151 } else if (!Objects.equals(this.getJobSkill(), jobPosition.getJobSkill())) {
153 } else if (!Objects.equals(this.getJobPositionSkillId(), jobPosition.getJobPositionSkillId())) {
161 public HireableJobPosition getJobPosition () {
162 return this.jobPosition;
166 public void setJobPosition (final HireableJobPosition jobPosition) {
167 this.jobPosition = jobPosition;
171 @SuppressWarnings ("ReturnOfDateField")
172 public Date getJobPositionSkillCreated () {
173 return this.jobPositionSkillCreated;
177 @SuppressWarnings ("AssignmentToDateFieldFromParameter")
178 public void setJobPositionSkillCreated (final Date jobPositionSkillCreated) {
179 this.jobPositionSkillCreated = jobPositionSkillCreated;
183 public Long getJobPositionSkillId () {
184 return this.jobPositionSkillId;
188 public void setJobPositionSkillId (final Long jobPositionSkillId) {
189 this.jobPositionSkillId = jobPositionSkillId;
193 @SuppressWarnings ("ReturnOfDateField")
194 public Date getJobPositionSkillUpdated () {
195 return this.jobPositionSkillUpdated;
199 @SuppressWarnings ("AssignmentToDateFieldFromParameter")
200 public void setJobPositionSkillUpdated (final Date jobPositionSkillUpdated) {
201 this.jobPositionSkillUpdated = jobPositionSkillUpdated;
205 public Skillable getJobSkill () {
206 return this.jobSkill;
210 public void setJobSkill (final Skillable jobSkill) {
211 this.jobSkill = jobSkill;
215 public User getSkillAddedUser () {
216 return this.skillAddedUser;
220 public void setSkillAddedUser (final User skillAddedUser) {
221 this.skillAddedUser = skillAddedUser;
225 public Short getSkillImportance () {
226 return this.skillImportance;
230 public void setSkillImportance (final Short skillImportance) {
231 this.skillImportance = skillImportance;
235 public int hashCode () {
238 hash = 41 * hash + Objects.hashCode(this.getJobPosition());
239 hash = 41 * hash + Objects.hashCode(this.getJobSkill());
240 hash = 41 * hash + Objects.hashCode(this.getSkillImportance());
241 hash = 41 * hash + Objects.hashCode(this.getJobPositionSkillId());