]> git.mxchange.org Git - jcontacts-business-core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sun, 10 May 2020 04:37:52 +0000 (06:37 +0200)
committerRoland Häder <roland@mxchange.org>
Sun, 10 May 2020 04:37:52 +0000 (06:37 +0200)
- added to re-add departmentLead in equals()/hashCode() methods but now as
  Contact and not Employee. In Employee you have a Department instance again,
  leading to endless recursive calls / stack overflow.

Signed-off-by: Roland Häder <roland@mxchange.org>
src/org/mxchange/jcontactsbusiness/model/department/BusinessDepartment.java
src/org/mxchange/jcontactsbusiness/model/department/Department.java

index bc2dcb677377347ecff670204dc3b7d090e5c670..d066b594c953b6e296b2a97b71ef05f021998a60 100644 (file)
@@ -34,13 +34,13 @@ import javax.persistence.Table;
 import javax.persistence.Temporal;
 import javax.persistence.TemporalType;
 import javax.persistence.Transient;
+import org.mxchange.jcontacts.model.contact.Contact;
+import org.mxchange.jcontacts.model.contact.UserContact;
 import org.mxchange.jcontactsbusiness.model.basicdata.BasicData;
 import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData;
 import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice;
 import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffices;
 import org.mxchange.jcontactsbusiness.model.branchoffice.BusinessBranchOffice;
-import org.mxchange.jcontactsbusiness.model.employee.BusinessEmployee;
-import org.mxchange.jcontactsbusiness.model.employee.Employable;
 import org.mxchange.jcontactsbusiness.model.headquarter.BusinessHeadquarter;
 import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter;
 import org.mxchange.jcontactsbusiness.model.headquarter.Headquarters;
@@ -121,11 +121,11 @@ public class BusinessDepartment implements Department {
        private Long departmentId;
 
        /**
-        * Department lead employee
+        * Department lead contact data
         */
        @JoinColumn (name = "department_lead_id")
-       @OneToOne (targetEntity = BusinessEmployee.class, cascade = CascadeType.REFRESH)
-       private Employable departmentLead;
+       @OneToOne (targetEntity = UserContact.class, cascade = CascadeType.REFRESH)
+       private Contact departmentLead;
 
        /**
         * User owner instance
@@ -217,6 +217,8 @@ public class BusinessDepartment implements Department {
                        return false;
                } else if (!Objects.equals(this.getDepartmentId(), department.getDepartmentId())) {
                        return false;
+               } else if (!Objects.equals(this.getDepartmentLead(), department.getDepartmentLead())) {
+                       return false;
                } else if (!Objects.equals(this.getDepartmentUserOwner(), department.getDepartmentUserOwner())) {
                        return false;
                }
@@ -299,12 +301,12 @@ public class BusinessDepartment implements Department {
        }
 
        @Override
-       public Employable getDepartmentLead () {
+       public Contact getDepartmentLead () {
                return this.departmentLead;
        }
 
        @Override
-       public void setDepartmentLead (final Employable departmentLead) {
+       public void setDepartmentLead (final Contact departmentLead) {
                this.departmentLead = departmentLead;
        }
 
@@ -327,6 +329,7 @@ public class BusinessDepartment implements Department {
                hash = 53 * hash + Objects.hashCode(this.getDepartmentHeadquarter());
                hash = 53 * hash + Objects.hashCode(this.getDepartmentId());
                hash = 53 * hash + Objects.hashCode(this.getDepartmentI18nKey());
+               hash = 53 * hash + Objects.hashCode(this.getDepartmentLead());
                hash = 53 * hash + Objects.hashCode(this.getDepartmentUserOwner());
 
                return hash;
index dcfa260f244ec78b208933357c8a8122af847a02..59fb6796dd53a9f3cbc5d91d7141635a9e35f08b 100644 (file)
@@ -18,9 +18,9 @@ package org.mxchange.jcontactsbusiness.model.department;
 
 import java.io.Serializable;
 import java.util.Date;
+import org.mxchange.jcontacts.model.contact.Contact;
 import org.mxchange.jcontactsbusiness.model.basicdata.BasicData;
 import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice;
-import org.mxchange.jcontactsbusiness.model.employee.Employable;
 import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter;
 import org.mxchange.jusercore.model.user.User;
 
@@ -88,18 +88,18 @@ public interface Department extends Comparable<Department>, Serializable {
        void setDepartmentId (final Long departmentId);
 
        /**
-        * Getter for department lead employee
+        * Getter for department lead contact
         * <p>
-        * @return Department lead employee
+        * @return Department lead contact
         */
-       Employable getDepartmentLead ();
+       Contact getDepartmentLead ();
 
        /**
-        * Setter for department lead employee
+        * Setter for department lead contact
         * <p>
-        * @param departmentLead Department lead employee
+        * @param departmentLead Department lead contact
         */
-       void setDepartmentLead (final Employable departmentLead);
+       void setDepartmentLead (final Contact departmentLead);
 
        /**
         * Getter for department i18n key