From df5a120bb62ab52e870e2499b49f3a55bc921fea Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 10 May 2020 06:57:40 +0200 Subject: [PATCH] Continued: - also headquarter cannot have direct reference to employee as this would result in recursive call as the headquarter's employee may also be compared MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../model/headquarter/BusinessHeadquarter.java | 17 ++++++++++------- .../model/headquarter/Headquarter.java | 10 +++++----- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/org/mxchange/jcontactsbusiness/model/headquarter/BusinessHeadquarter.java b/src/org/mxchange/jcontactsbusiness/model/headquarter/BusinessHeadquarter.java index 27923e1..36c8f20 100644 --- a/src/org/mxchange/jcontactsbusiness/model/headquarter/BusinessHeadquarter.java +++ b/src/org/mxchange/jcontactsbusiness/model/headquarter/BusinessHeadquarter.java @@ -38,8 +38,8 @@ import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.persistence.Transient; import org.apache.commons.lang3.StringUtils; -import org.mxchange.jcontactsbusiness.model.employee.BusinessEmployee; -import org.mxchange.jcontactsbusiness.model.employee.Employable; +import org.mxchange.jcontacts.model.contact.Contact; +import org.mxchange.jcontacts.model.contact.UserContact; import org.mxchange.jcontactsbusiness.model.opening_time.BusinessOpeningTime; import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime; import org.mxchange.jcoreutils.Comparables; @@ -91,9 +91,9 @@ public class BusinessHeadquarter implements Headquarter { /** * Reference to contact person */ - @JoinColumn (name = "headquarter_contact_employee_id", referencedColumnName = "employee_id") - @OneToOne (targetEntity = BusinessEmployee.class, cascade = CascadeType.REFRESH) - private Employable headquarterContactEmployee; + @JoinColumn (name = "headquarter_contact_employee_id", referencedColumnName = "contact_id") + @OneToOne (targetEntity = UserContact.class, cascade = CascadeType.REFRESH) + private Contact headquarterContactEmployee; /** * Headquarter's country code @@ -346,6 +346,8 @@ public class BusinessHeadquarter implements Headquarter { return false; } else if (!Objects.equals(this.getHeadquarterCompanyName(), headquarter.getHeadquarterCompanyName())) { return false; + } else if (!Objects.equals(this.getHeadquarterContactEmployee(), headquarter.getHeadquarterContactEmployee())) { + return false; } else if (!Objects.equals(this.getHeadquarterCountry(), headquarter.getHeadquarterCountry())) { return false; } else if (!Objects.equals(this.getHeadquarterEmailAddress(), headquarter.getHeadquarterEmailAddress())) { @@ -396,12 +398,12 @@ public class BusinessHeadquarter implements Headquarter { } @Override - public Employable getHeadquarterContactEmployee () { + public Contact getHeadquarterContactEmployee () { return this.headquarterContactEmployee; } @Override - public void setHeadquarterContactEmployee (final Employable headquarterContactEmployee) { + public void setHeadquarterContactEmployee (final Contact headquarterContactEmployee) { this.headquarterContactEmployee = headquarterContactEmployee; } @@ -577,6 +579,7 @@ public class BusinessHeadquarter implements Headquarter { hash = 47 * hash + Objects.hashCode(this.getHeadquarterCity()); hash = 47 * hash + Objects.hashCode(this.getHeadquarterCompanyName()); + hash = 47 * hash + Objects.hashCode(this.getHeadquarterContactEmployee()); hash = 47 * hash + Objects.hashCode(this.getHeadquarterCountry()); hash = 47 * hash + Objects.hashCode(this.getHeadquarterEmailAddress()); hash = 47 * hash + Objects.hashCode(this.getHeadquarterFaxNumber()); diff --git a/src/org/mxchange/jcontactsbusiness/model/headquarter/Headquarter.java b/src/org/mxchange/jcontactsbusiness/model/headquarter/Headquarter.java index c9eff4e..19a02e0 100644 --- a/src/org/mxchange/jcontactsbusiness/model/headquarter/Headquarter.java +++ b/src/org/mxchange/jcontactsbusiness/model/headquarter/Headquarter.java @@ -19,7 +19,7 @@ package org.mxchange.jcontactsbusiness.model.headquarter; import java.io.Serializable; import java.util.Date; import java.util.List; -import org.mxchange.jcontactsbusiness.model.employee.Employable; +import org.mxchange.jcontacts.model.contact.Contact; import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime; import org.mxchange.jcountry.model.data.Country; import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; @@ -230,18 +230,18 @@ public interface Headquarter extends Comparable, Serializable { void setHeadquarterUserOwner (final User headquarterUserOwner); /** - * Getter for branch office owning employee + * Getter for branch office owning contact *

- * @return Owning employee + * @return Owning contact */ - Employable getHeadquarterContactEmployee (); + Contact getHeadquarterContactEmployee (); /** * Setter for branch office contact person *

* @param branchContactEmployee Contact person */ - void setHeadquarterContactEmployee (final Employable branchContactEmployee); + void setHeadquarterContactEmployee (final Contact branchContactEmployee); /** * Getter for opening times for this branch office -- 2.39.5