]> git.mxchange.org Git - jcontacts-business-core.git/blobdiff - src/org/mxchange/jcontactsbusiness/jobposition/EmployeePosition.java
user (owner) is now optional and renamed
[jcontacts-business-core.git] / src / org / mxchange / jcontactsbusiness / jobposition / EmployeePosition.java
index d17272bc68c14d94bf244e69565d7888b96b5729..033c2d4aa9d94361752453917ef75dd67b3f4fe2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 Roland Haeder
+ * Copyright (C) 2016, 2017 Roland Häder
  *
  * 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
@@ -16,6 +16,7 @@
  */
 package org.mxchange.jcontactsbusiness.jobposition;
 
+import java.util.Calendar;
 import java.util.Objects;
 import javax.persistence.Basic;
 import javax.persistence.Column;
@@ -23,58 +24,100 @@ import javax.persistence.Entity;
 import javax.persistence.GeneratedValue;
 import javax.persistence.GenerationType;
 import javax.persistence.Id;
+import javax.persistence.Index;
 import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.persistence.Transient;
 
 /**
  * A POJO for job positions
  * <p>
- * @author Roland Haeder
+ * @author Roland Häder<roland@mxchange.org>
  */
-@Entity (name = "job_positions")
-@Table (name = "job_positions")
-public class EmployeePosition implements JobPosition, Comparable<JobPosition> {
+@Entity (name = "company_job_positions")
+@Table (
+               name = "company_job_positions",
+               indexes = {
+                       @Index (
+                                       name = "job_position",
+                                       columnList = "job_position_name",
+                                       unique = true
+                       )
+               }
+)
+@SuppressWarnings ("PersistenceUnitPresent")
+public class EmployeePosition implements JobPosition {
 
        /**
         * Serial number
         */
+       @Transient
        private static final long serialVersionUID = 18_427_587_187_609L;
 
+       /**
+        * Timestamp when this entry has been created
+        */
+       @Basic (optional = false)
+       @Temporal (TemporalType.TIMESTAMP)
+       @Column (name = "job_position_created", nullable = false, updatable = false)
+       private Calendar jobPositionCreated;
+
        /**
         * Id number
         */
        @Id
        @GeneratedValue (strategy = GenerationType.IDENTITY)
-       @Column (name = "job_position_id", length = 20, nullable = false, updatable = false)
+       @Column (name = "job_position_id", 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)
+       @Column (name = "job_position_name", 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.
-       }
+       /**
+        * Timestamp when this entry has been created
+        */
+       @Temporal (TemporalType.TIMESTAMP)
+       @Column (name = "job_position_updated", insertable = false)
+       private Calendar jobPositionUpdated;
 
        @Override
        public boolean equals (final Object object) {
-               if (object == null) {
+               if (this == object) {
+                       return true;
+               } else if (null == object) {
                        return false;
-               } else if (getClass() != object.getClass()) {
+               } else if (this.getClass() != object.getClass()) {
                        return false;
                }
 
                final JobPosition other = (JobPosition) object;
 
-               if (!Objects.equals(this.getJobPositionName(), other.getJobPositionName())) {
+               if (!Objects.equals(this.getJobPositionId(), other.getJobPositionId())) {
+                       return false;
+               } else if (!Objects.equals(this.getJobPositionName(), other.getJobPositionName())) {
                        return false;
                }
+
                return true;
        }
 
+       @Override
+       @SuppressWarnings ("ReturnOfDateField")
+       public Calendar getJobPositionCreated () {
+               return this.jobPositionCreated;
+       }
+
+       @Override
+       @SuppressWarnings ("AssignmentToDateFieldFromParameter")
+       public void setJobPositionCreated (final Calendar jobPositionCreated) {
+               this.jobPositionCreated = jobPositionCreated;
+       }
+
        @Override
        public Long getJobPositionId () {
                return this.jobPositionId;
@@ -95,10 +138,25 @@ public class EmployeePosition implements JobPosition, Comparable<JobPosition> {
                this.jobPositionName = jobPositionName;
        }
 
+       @Override
+       @SuppressWarnings ("ReturnOfDateField")
+       public Calendar getJobPositionUpdated () {
+               return this.jobPositionUpdated;
+       }
+
+       @Override
+       @SuppressWarnings ("AssignmentToDateFieldFromParameter")
+       public void setJobPositionUpdated (final Calendar jobPositionUpdated) {
+               this.jobPositionUpdated = jobPositionUpdated;
+       }
+
        @Override
        public int hashCode () {
                int hash = 7;
+
+               hash = 37 * hash + Objects.hashCode(this.getJobPositionId());
                hash = 37 * hash + Objects.hashCode(this.getJobPositionName());
+
                return hash;
        }