From 4baade5df65346398c881cd06795548d2d9c2ff5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 10 Oct 2019 22:46:53 +0200 Subject: [PATCH] Continued: - renamed JobPosition to HireableJobPosition (tpzo in first syllable) and added methods from jjobs-core as this was redundant anyway (and didn't work in the end) - added JobPositionStatus (enum) from jjobs-core MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../model/employee/BusinessEmployee.java | 12 +- .../model/employee/Employable.java | 6 +- .../model/jobposition/EmployeePosition.java | 133 ++++++++++++- .../jobposition/HireableJobPosition.java | 177 ++++++++++++++++++ .../model/jobposition/JobPosition.java | 91 --------- .../model/jobposition/JobPositions.java | 2 +- .../jobposition/status/JobPositionStatus.java | 91 +++++++++ 7 files changed, 408 insertions(+), 104 deletions(-) create mode 100644 src/org/mxchange/jcontactsbusiness/model/jobposition/HireableJobPosition.java delete mode 100644 src/org/mxchange/jcontactsbusiness/model/jobposition/JobPosition.java create mode 100644 src/org/mxchange/jcontactsbusiness/model/jobposition/status/JobPositionStatus.java diff --git a/src/org/mxchange/jcontactsbusiness/model/employee/BusinessEmployee.java b/src/org/mxchange/jcontactsbusiness/model/employee/BusinessEmployee.java index aaed986..f4c695a 100644 --- a/src/org/mxchange/jcontactsbusiness/model/employee/BusinessEmployee.java +++ b/src/org/mxchange/jcontactsbusiness/model/employee/BusinessEmployee.java @@ -49,7 +49,7 @@ import org.mxchange.jcontactsbusiness.model.headquarter.BusinessHeadquarter; import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; import org.mxchange.jcontactsbusiness.model.headquarter.Headquarters; import org.mxchange.jcontactsbusiness.model.jobposition.EmployeePosition; -import org.mxchange.jcontactsbusiness.model.jobposition.JobPosition; +import org.mxchange.jcontactsbusiness.model.jobposition.HireableJobPosition; import org.mxchange.jcontactsbusiness.model.jobposition.JobPositions; import org.mxchange.jcoreutils.Comparables; import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber; @@ -132,7 +132,7 @@ public class BusinessEmployee implements Employable { */ @JoinColumn (name = "employee_position_id") @OneToOne (targetEntity = EmployeePosition.class, cascade = CascadeType.REFRESH) - private JobPosition employeeJobPosition; + private HireableJobPosition employeeJobPosition; /** * Employee's business mobile number @@ -213,6 +213,9 @@ public class BusinessEmployee implements Employable { // Init comparisons final int[] comparators = { + // First employee's number + // First employee's number + // First employee's number // First employee's number StringUtils.compareIgnoreCase(this.getEmployeeNumber(), employable.getEmployeeNumber()), // ... finally contact data @@ -221,7 +224,6 @@ public class BusinessEmployee implements Employable { StringUtils.compareIgnoreCase(this.getEmployeeEmailAddress(), employable.getEmployeeEmailAddress()), // ... company data (BasicData) this.getEmployeeBasicData().compareTo(employable.getEmployeeBasicData()), - // ... job position JobPositions.compare(this.getEmployeeJobPosition(), employable.getEmployeeJobPosition()), // ... department Departments.compare(this.getEmployeeDepartment(), employable.getEmployeeDepartment()), @@ -334,12 +336,12 @@ public class BusinessEmployee implements Employable { } @Override - public JobPosition getEmployeeJobPosition () { + public HireableJobPosition getEmployeeJobPosition () { return this.employeeJobPosition; } @Override - public void setEmployeeJobPosition (final JobPosition employeeJobPosition) { + public void setEmployeeJobPosition (final HireableJobPosition employeeJobPosition) { this.employeeJobPosition = employeeJobPosition; } diff --git a/src/org/mxchange/jcontactsbusiness/model/employee/Employable.java b/src/org/mxchange/jcontactsbusiness/model/employee/Employable.java index 1eec65b..7d9e16d 100644 --- a/src/org/mxchange/jcontactsbusiness/model/employee/Employable.java +++ b/src/org/mxchange/jcontactsbusiness/model/employee/Employable.java @@ -23,7 +23,7 @@ import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice; import org.mxchange.jcontactsbusiness.model.department.Department; import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; -import org.mxchange.jcontactsbusiness.model.jobposition.JobPosition; +import org.mxchange.jcontactsbusiness.model.jobposition.HireableJobPosition; import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber; import org.mxchange.jusercore.model.user.User; @@ -179,14 +179,14 @@ public interface Employable extends Comparable, Serializable { *

* @return Employable's position */ - JobPosition getEmployeeJobPosition (); + HireableJobPosition getEmployeeJobPosition (); /** * Setter for employee's position *

* @param employeePosition Employable's position */ - void setEmployeeJobPosition (final JobPosition employeePosition); + void setEmployeeJobPosition (final HireableJobPosition employeePosition); /** * Getter for user owner instance diff --git a/src/org/mxchange/jcontactsbusiness/model/jobposition/EmployeePosition.java b/src/org/mxchange/jcontactsbusiness/model/jobposition/EmployeePosition.java index 7c6e933..be455e3 100644 --- a/src/org/mxchange/jcontactsbusiness/model/jobposition/EmployeePosition.java +++ b/src/org/mxchange/jcontactsbusiness/model/jobposition/EmployeePosition.java @@ -19,16 +19,24 @@ package org.mxchange.jcontactsbusiness.model.jobposition; import java.util.Date; import java.util.Objects; import javax.persistence.Basic; +import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.OneToOne; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.persistence.Transient; +import org.mxchange.jcontactsbusiness.model.jobposition.status.JobPositionStatus; import org.mxchange.jcoreutils.Comparables; +import org.mxchange.jusercore.model.user.LoginUser; +import org.mxchange.jusercore.model.user.User; /** * A POJO for job positions @@ -40,7 +48,7 @@ import org.mxchange.jcoreutils.Comparables; name = "company_job_positions" ) @SuppressWarnings ("PersistenceUnitPresent") -public class EmployeePosition implements JobPosition { +public class EmployeePosition implements HireableJobPosition { /** * Serial number @@ -48,6 +56,13 @@ public class EmployeePosition implements JobPosition { @Transient private static final long serialVersionUID = 18_427_587_187_609L; + /** + * User who has added this job position + */ + @JoinColumn (name = "job_position_added_user_id", referencedColumnName = "user_id", updatable = false) + @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.REFRESH, optional = false) + private User jobPositionAddedUser; + /** * Timestamp when this entry has been created */ @@ -56,6 +71,27 @@ public class EmployeePosition implements JobPosition { @Column (name = "job_position_created", nullable = false, updatable = false) private Date jobPositionCreated; + /** + * When this job position (offer) was deleted + */ + @Column (name = "job_position_deleted") + @Temporal (TemporalType.TIMESTAMP) + private Date jobPositionDeleted; + + /** + * When this job position (offer) has expired + */ + @Column (name = "job_position_expired") + @Temporal (TemporalType.TIMESTAMP) + private Date jobPositionExpired; + + /** + * When a new employed was hired for this job position + */ + @Column (name = "job_position_hired") + @Temporal (TemporalType.TIMESTAMP) + private Date jobPositionHired; + /** * Id number */ @@ -71,6 +107,22 @@ public class EmployeePosition implements JobPosition { @Column (name = "job_position_name", nullable = false, unique = true) private String jobPositionName; + /** + * When this job position (offer) starts + */ + @Basic (optional = false) + @Column (name = "job_position_start", nullable = false) + @Temporal (TemporalType.DATE) + private Date jobPositionStart; + + /** + * Job position status + */ + @Basic (optional = false) + @Column (name = "job_position_status", nullable = false) + @Enumerated (EnumType.STRING) + private JobPositionStatus jobPositionStatus; + /** * Timestamp when this entry has been created */ @@ -79,7 +131,7 @@ public class EmployeePosition implements JobPosition { private Date jobPositionUpdated; @Override - public int compareTo (final JobPosition jobPosition) { + public int compareTo (final HireableJobPosition jobPosition) { // Check parameter on null-reference and equality to this if (null == jobPosition) { // Should not happen @@ -91,7 +143,9 @@ public class EmployeePosition implements JobPosition { // Init comparisons final int[] comparators = { - // First position name ... + // First added by which user ... + this.getJobPositionAddedUser().compareTo(jobPosition.getJobPositionAddedUser()), + // ... next name this.getJobPositionName().compareToIgnoreCase(jobPosition.getJobPositionName()) }; @@ -112,17 +166,29 @@ public class EmployeePosition implements JobPosition { return false; } - final JobPosition other = (JobPosition) object; + final HireableJobPosition other = (HireableJobPosition) object; if (!Objects.equals(this.getJobPositionId(), other.getJobPositionId())) { return false; } else if (!Objects.equals(this.getJobPositionName(), other.getJobPositionName())) { return false; + } else if (!Objects.equals(this.getJobPositionAddedUser(), other.getJobPositionAddedUser())) { + return false; } return true; } + @Override + public User getJobPositionAddedUser () { + return this.jobPositionAddedUser; + } + + @Override + public void setJobPositionAddedUser (final User jobPositionAddedUser) { + this.jobPositionAddedUser = jobPositionAddedUser; + } + @Override @SuppressWarnings ("ReturnOfDateField") public Date getJobPositionCreated () { @@ -167,12 +233,71 @@ public class EmployeePosition implements JobPosition { this.jobPositionUpdated = jobPositionUpdated; } + @Override + @SuppressWarnings ("ReturnOfDateField") + public Date getJobPositionDeleted () { + return this.jobPositionDeleted; + } + + @Override + @SuppressWarnings ("AssignmentToDateFieldFromParameter") + public void setJobPositionDeleted (final Date jobPositionDeleted) { + this.jobPositionDeleted = jobPositionDeleted; + } + + @Override + @SuppressWarnings ("ReturnOfDateField") + public Date getJobPositionExpired () { + return this.jobPositionExpired; + } + + @Override + @SuppressWarnings ("AssignmentToDateFieldFromParameter") + public void setJobPositionExpired (final Date jobPositionExpired) { + this.jobPositionExpired = jobPositionExpired; + } + + @Override + @SuppressWarnings ("ReturnOfDateField") + public Date getJobPositionHired () { + return this.jobPositionHired; + } + + @Override + @SuppressWarnings ("AssignmentToDateFieldFromParameter") + public void setJobPositionHired (final Date jobPositionHired) { + this.jobPositionHired = jobPositionHired; + } + + @Override + @SuppressWarnings ("ReturnOfDateField") + public Date getJobPositionStart () { + return this.jobPositionStart; + } + + @Override + @SuppressWarnings ("AssignmentToDateFieldFromParameter") + public void setJobPositionStart (final Date jobPositionStart) { + this.jobPositionStart = jobPositionStart; + } + + @Override + public JobPositionStatus getJobPositionStatus () { + return this.jobPositionStatus; + } + + @Override + public void setJobPositionStatus (final JobPositionStatus jobPositionStatus) { + this.jobPositionStatus = jobPositionStatus; + } + @Override public int hashCode () { int hash = 7; hash = 37 * hash + Objects.hashCode(this.getJobPositionId()); hash = 37 * hash + Objects.hashCode(this.getJobPositionName()); + hash = 37 * hash + Objects.hashCode(this.getJobPositionAddedUser()); return hash; } diff --git a/src/org/mxchange/jcontactsbusiness/model/jobposition/HireableJobPosition.java b/src/org/mxchange/jcontactsbusiness/model/jobposition/HireableJobPosition.java new file mode 100644 index 0000000..f62913f --- /dev/null +++ b/src/org/mxchange/jcontactsbusiness/model/jobposition/HireableJobPosition.java @@ -0,0 +1,177 @@ +/* + * Copyright (C) 2016 - 2018 Free Software Foundation + * + * 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.model.jobposition; + +import java.io.Serializable; +import java.util.Date; +import org.mxchange.jcontactsbusiness.model.jobposition.status.JobPositionStatus; +import org.mxchange.jusercore.model.user.User; + +/** + * A POJI for job positions + *

+ * @author Roland Häder + */ +public interface HireableJobPosition extends Comparable, Serializable { + + /** + * Getter for id number + *

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

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

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

+ * @param jobPositionName Job position name + */ + void setJobPositionName (final String jobPositionName); + + /** + * Getter for timestamp when this entry has been created + *

+ * @return Timestamp when this entry has been created + */ + Date getJobPositionCreated (); + + /** + * Setter for timestamp when this entry has been created + *

+ * @param jobPositionCreated Timestamp when this entry has been created + */ + void setJobPositionCreated (final Date jobPositionCreated); + + /** + * Getter for timestamp when this entry has been updated + *

+ * @return Timestamp when this entry has been updated + */ + Date getJobPositionUpdated (); + + /** + * Setter for timestamp when this entry has been updated + *

+ * @param jobPositionUpdated Timestamp when this entry has been updated + */ + void setJobPositionUpdated (final Date jobPositionUpdated); + + /** + * Getter for job position start + *

+ * @return Job position start + */ + Date getJobPositionStart (); + + /** + * Setter for job position start + *

+ * @param jobPositionStart Job position start + */ + void setJobPositionStart (final Date jobPositionStart); + + /** + * Getter for job position status + *

+ * @return Job position status + */ + JobPositionStatus getJobPositionStatus (); + + /** + * Setter for job position status + *

+ * @param jobPositionStatus Job position status + */ + void setJobPositionStatus (final JobPositionStatus jobPositionStatus); + + /** + * Getter for when this job position was deleted by user + *

+ * @return When this job position was deleted by user + */ + Date getJobPositionDeleted (); + + /** + * Setter for when this job position was deleted by user + *

+ * @param jobPositionDeleted When this job position was deleted by user + */ + void setJobPositionDeleted (final Date jobPositionDeleted); + + /** + * Getter for when this job position has expired + *

+ * @return When this job position has expired + */ + Date getJobPositionExpired (); + + /** + * Setter for when this job position has expired + *

+ * @param jobPositionExpired When this job position has expired + */ + void setJobPositionExpired (final Date jobPositionExpired); + + /** + * Getter for when employee was hired for this job position + *

+ * @return When employee was hired for this job position + */ + Date getJobPositionHired (); + + /** + * Setter for when employee was hired for this job position + *

+ * @param jobPositionHired When employee was hired for this job position + */ + void setJobPositionHired (final Date jobPositionHired); + + /** + * Getter for user who added this job position + *

+ * @return User who added this job position + */ + User getJobPositionAddedUser (); + + /** + * Setter for user who added this job position + *

+ * @param jobPositionAddedUser User who added this job position + */ + void setJobPositionAddedUser (final User jobPositionAddedUser); + + @Override + boolean equals (final Object object); + + @Override + int hashCode (); + +} diff --git a/src/org/mxchange/jcontactsbusiness/model/jobposition/JobPosition.java b/src/org/mxchange/jcontactsbusiness/model/jobposition/JobPosition.java deleted file mode 100644 index 01e2335..0000000 --- a/src/org/mxchange/jcontactsbusiness/model/jobposition/JobPosition.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (C) 2016 - 2018 Free Software Foundation - * - * 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.model.jobposition; - -import java.io.Serializable; -import java.util.Date; - -/** - * A POJI for job positions - *

- * @author Roland Häder - */ -public interface JobPosition extends Comparable, Serializable { - - /** - * Getter for id number - *

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

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

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

- * @param jobPositionName Job position name - */ - void setJobPositionName (final String jobPositionName); - - /** - * Getter for timestamp when this entry has been created - *

- * @return Timestamp when this entry has been created - */ - Date getJobPositionCreated (); - - /** - * Setter for timestamp when this entry has been created - *

- * @param jobPositionCreated Timestamp when this entry has been created - */ - void setJobPositionCreated (final Date jobPositionCreated); - - /** - * Getter for timestamp when this entry has been updated - *

- * @return Timestamp when this entry has been updated - */ - Date getJobPositionUpdated (); - - /** - * Setter for timestamp when this entry has been updated - *

- * @param jobPositionUpdated Timestamp when this entry has been updated - */ - void setJobPositionUpdated (final Date jobPositionUpdated); - - @Override - boolean equals (final Object object); - - @Override - int hashCode (); - -} diff --git a/src/org/mxchange/jcontactsbusiness/model/jobposition/JobPositions.java b/src/org/mxchange/jcontactsbusiness/model/jobposition/JobPositions.java index a23be98..c3d8864 100644 --- a/src/org/mxchange/jcontactsbusiness/model/jobposition/JobPositions.java +++ b/src/org/mxchange/jcontactsbusiness/model/jobposition/JobPositions.java @@ -40,7 +40,7 @@ public class JobPositions implements Serializable { *

* @return Comparison value */ - public static int compare (final JobPosition jobPosition1, final JobPosition jobPosition2) { + public static int compare (final HireableJobPosition jobPosition1, final HireableJobPosition jobPosition2) { // Check euqality, then at least first must be given if (Objects.equals(jobPosition1, jobPosition2)) { // Both are same diff --git a/src/org/mxchange/jcontactsbusiness/model/jobposition/status/JobPositionStatus.java b/src/org/mxchange/jcontactsbusiness/model/jobposition/status/JobPositionStatus.java new file mode 100644 index 0000000..30584b4 --- /dev/null +++ b/src/org/mxchange/jcontactsbusiness/model/jobposition/status/JobPositionStatus.java @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2016 - 2019 Free Software Foundation + * + * 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.model.jobposition.status; + +/** + * An enumeration for job position status + *

+ * @author Roland Häder + */ +public enum JobPositionStatus { + + /** + * Open job position status (open for applications) + */ + OPEN("JOB_POSITION_STATUS_OPEN", "job_position_status_open"), //NOI18N + + /** + * Hired job position status (new employee) + */ + HIRED("JOB_POSITION_STATUS_HIRED", "job_position_status_hired"), //NOI18N + + /** + * Deleted job position status (by user) + */ + DELETED("JOB_POSITION_STATUS_DELETED", "job_position_status_deleted"), //NOI18N + + /** + * Expired job position status (when no one applied for it) + */ + EXPIRED("JOB_POSITION_STATUS_DELETED", "job_position_status_expired"), //NOI18N + + /** + * Locked job position status (by administrator) + */ + LOCKED("JOB_POSITION_STATUS_LOCKED", "job_position_status_locked"); //NOI18N + + /** + * Message key for bundles + */ + private final String messageKey; + + /** + * CSS class + */ + private final String styleClass; + + /** + * Constructor with message key and CSS class + *

+ * @param messageKey Message key + * @param styleClass CSS class + */ + private JobPositionStatus (final String messageKey, final String styleClass) { + // Set all + this.messageKey = messageKey; + this.styleClass = styleClass; + } + + /** + * Getter for i18n bundle message key + *

+ * @return Message key for i18n bundles + */ + public String getMessageKey () { + return this.messageKey; + } + + /** + * Getter for CSS class + *

+ * @return CSS class + */ + public String getStyleClass () { + return this.styleClass; + } + +} -- 2.39.2