From: Roland Häder <roland@mxchange.org>
Date: Sun, 24 Sep 2017 19:13:57 +0000 (+0200)
Subject: Continued:
X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e9ab32684b1eed8b530084e722821a0ab65a7973;p=jcontacts-business-core.git

Continued:
- user "owner" is no longer required for employee as it may not be available at
  all times
- one opening-times line is maybe not enough as they may varry from day to day

Signed-off-by: Roland Häder <roland@mxchange.org>
---

diff --git a/src/org/mxchange/jcontactsbusiness/model/branchoffice/BranchOffice.java b/src/org/mxchange/jcontactsbusiness/model/branchoffice/BranchOffice.java
index d179997..798316c 100644
--- a/src/org/mxchange/jcontactsbusiness/model/branchoffice/BranchOffice.java
+++ b/src/org/mxchange/jcontactsbusiness/model/branchoffice/BranchOffice.java
@@ -18,6 +18,7 @@ package org.mxchange.jcontactsbusiness.model.branchoffice;
 
 import java.io.Serializable;
 import java.util.Date;
+import java.util.List;
 import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData;
 import org.mxchange.jcontactsbusiness.model.employee.Employee;
 import org.mxchange.jcontactsbusiness.model.opening_times.OpeningTimes;
@@ -164,14 +165,14 @@ public interface BranchOffice extends Serializable {
 	 * <p>
 	 * @return Opening times
 	 */
-	OpeningTimes getBranchOpeningTimes ();
+	List<OpeningTimes> getBranchOpeningTimes ();
 
 	/**
 	 * Setter for opening times for this branch office
 	 * <p>
 	 * @param branchOpeningTimes Opening times
 	 */
-	void setBranchOpeningTimes (final OpeningTimes branchOpeningTimes);
+	void setBranchOpeningTimes (final List<OpeningTimes> branchOpeningTimes);
 
 	/**
 	 * Getter for branch office owning employee
diff --git a/src/org/mxchange/jcontactsbusiness/model/branchoffice/CompanyBranchOffice.java b/src/org/mxchange/jcontactsbusiness/model/branchoffice/CompanyBranchOffice.java
index 3dfed1a..e747688 100644
--- a/src/org/mxchange/jcontactsbusiness/model/branchoffice/CompanyBranchOffice.java
+++ b/src/org/mxchange/jcontactsbusiness/model/branchoffice/CompanyBranchOffice.java
@@ -18,6 +18,7 @@ package org.mxchange.jcontactsbusiness.model.branchoffice;
 
 import java.text.MessageFormat;
 import java.util.Date;
+import java.util.List;
 import java.util.Objects;
 import javax.persistence.Basic;
 import javax.persistence.CascadeType;
@@ -27,6 +28,8 @@ import javax.persistence.GeneratedValue;
 import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
+import javax.persistence.ManyToMany;
 import javax.persistence.NamedQueries;
 import javax.persistence.NamedQuery;
 import javax.persistence.OneToOne;
@@ -38,6 +41,7 @@ import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData;
 import org.mxchange.jcontactsbusiness.model.basicdata.CompanyBasicData;
 import org.mxchange.jcontactsbusiness.model.employee.CompanyEmployee;
 import org.mxchange.jcontactsbusiness.model.employee.Employee;
+import org.mxchange.jcontactsbusiness.model.opening_times.BusinessOpeningTimes;
 import org.mxchange.jcontactsbusiness.model.opening_times.OpeningTimes;
 import org.mxchange.jcountry.model.data.Country;
 import org.mxchange.jcountry.model.data.CountryData;
@@ -115,7 +119,7 @@ public class CompanyBranchOffice implements BranchOffice {
 	/**
 	 * Branch office's main fax number: +ccxxxxxxxxxx
 	 */
-	@JoinColumn (name = "branch_fax_number_id", referencedColumnName = "id_id")
+	@JoinColumn (name = "branch_fax_number_id", referencedColumnName = "fax_id")
 	@OneToOne (targetEntity = FaxNumber.class, cascade = CascadeType.ALL)
 	private DialableFaxNumber branchFaxNumber;
 
@@ -150,9 +154,9 @@ public class CompanyBranchOffice implements BranchOffice {
 	/**
 	 * Opening times for this branch office
 	 */
-	@JoinColumn (name = "branch_owner_employee_id", referencedColumnName = "opening_times_id")
-	@OneToOne (targetEntity = CompanyEmployee.class, cascade = CascadeType.REFRESH)
-	private OpeningTimes branchOpeningTimes;
+	@JoinTable (name = "branch_opening_times", joinColumns = @JoinColumn(name = "branch_opening_id", referencedColumnName = "branch_id"), inverseJoinColumns = @JoinColumn(name = "opening_branch_id", referencedColumnName = "opening_times_id"))
+	@ManyToMany (targetEntity = BusinessOpeningTimes.class, cascade = CascadeType.REFRESH)
+	private List<OpeningTimes> branchOpeningTimes;
 
 	/**
 	 * Reference to branch office owner (for example some franchise supermarkets
@@ -417,12 +421,12 @@ public class CompanyBranchOffice implements BranchOffice {
 	}
 
 	@Override
-	public OpeningTimes getBranchOpeningTimes () {
+	public List<OpeningTimes> getBranchOpeningTimes () {
 		return this.branchOpeningTimes;
 	}
 
 	@Override
-	public void setBranchOpeningTimes (final OpeningTimes branchOpeningTimes) {
+	public void setBranchOpeningTimes (final List<OpeningTimes> branchOpeningTimes) {
 		this.branchOpeningTimes = branchOpeningTimes;
 	}
 
diff --git a/src/org/mxchange/jcontactsbusiness/model/employee/CompanyEmployee.java b/src/org/mxchange/jcontactsbusiness/model/employee/CompanyEmployee.java
index cda90b1..ad54a5c 100644
--- a/src/org/mxchange/jcontactsbusiness/model/employee/CompanyEmployee.java
+++ b/src/org/mxchange/jcontactsbusiness/model/employee/CompanyEmployee.java
@@ -158,8 +158,8 @@ public class CompanyEmployee implements Employee {
 	/**
 	 * User owner instance
 	 */
-	@JoinColumn (name = "employee_user_id", nullable = false, updatable = false)
-	@OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.REFRESH, optional = false)
+	@JoinColumn (name = "employee_user_id")
+	@OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.REFRESH)
 	private User employeeUserOwner;
 
 	@Override