]> git.mxchange.org Git - jcontacts-business-core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sun, 24 Sep 2017 19:13:57 +0000 (21:13 +0200)
committerRoland Häder <roland@mxchange.org>
Sun, 24 Sep 2017 19:13:57 +0000 (21:13 +0200)
- 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>
src/org/mxchange/jcontactsbusiness/model/branchoffice/BranchOffice.java
src/org/mxchange/jcontactsbusiness/model/branchoffice/CompanyBranchOffice.java
src/org/mxchange/jcontactsbusiness/model/employee/CompanyEmployee.java

index d17999728cd480435ba189393d275ba3152fdc63..798316c54f4af23f3b0469ef4acbceb8a0d1ef7a 100644 (file)
@@ -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
index 3dfed1a7a32d530ffc006940d75d58537bc6e5fe..e747688401082617e94597d9a86bebac0b4c2ed2 100644 (file)
@@ -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;
        }
 
index cda90b1c791f0ada93c69ce014cc6b9dd213956b..ad54a5c2cd85de116da6a21c25766dfc60e59224 100644 (file)
@@ -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