]> git.mxchange.org Git - pizzaservice-ejb.git/commitdiff
Please cherry-pick:
authorRoland Häder <roland@mxchange.org>
Mon, 11 May 2020 00:48:27 +0000 (02:48 +0200)
committerRoland Häder <roland@mxchange.org>
Wed, 10 Jun 2020 17:20:27 +0000 (19:20 +0200)
- departments, headquarters and branch offices cannot have a relation to
  employees as employess have a relation already to them. So if comparison of
  those entities come, this ends up in an endless loop with a stack overflow.
- the fix here is a bit simple and also a bit complex: relate those 3 entities
  to contacts (jcontacts-core.jar) and look in all employees related to the
  department, headquarter or branch office who have an equal contact record

Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/jcontactsbusiness/model/branchoffice/PizzaAdminBranchOfficeSessionBean.java
src/java/org/mxchange/jcontactsbusiness/model/department/PizzaAdminDepartmentSessionBean.java
src/java/org/mxchange/jcontactsbusiness/model/headquarter/PizzaAdminHeadquarterSessionBean.java

index 1b1d2a52b03df9857aafbccd3c2c089fa69b2629..177d2e77f59091e82a004afaddc7328bb4baee46 100644 (file)
@@ -21,6 +21,7 @@ import java.util.Date;
 import java.util.List;
 import javax.ejb.EJB;
 import javax.ejb.Stateless;
+import org.mxchange.jcontacts.model.contact.Contact;
 import org.mxchange.jcontactsbusiness.exceptions.branchoffice.BranchOfficeAlreadyAddedException;
 import org.mxchange.jcontactsbusiness.model.basicdata.BasicData;
 import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime;
@@ -76,6 +77,24 @@ public class PizzaAdminBranchOfficeSessionBean extends BasePizzaEnterpriseBean i
                // Add created timestamp
                branchOffice.setBranchEntryCreated(new Date());
 
+               // Is contact employee set?
+               if (branchOffice.getBranchContactEmployee() instanceof Contact) {
+                       // Get managed lead contact
+                       final Contact managedContact = this.createManaged(branchOffice.getBranchContactEmployee());
+
+                       // Set it back
+                       branchOffice.setBranchContactEmployee(managedContact);
+               }
+
+               // Is owner employee set?
+               if (branchOffice.getBranchOwnerEmployee() instanceof Contact) {
+                       // Get managed lead contact
+                       final Contact managedContact = this.createManaged(branchOffice.getBranchOwnerEmployee());
+
+                       // Set it back
+                       branchOffice.setBranchOwnerEmployee(managedContact);
+               }
+
                // Is user instance set?
                if (branchOffice.getBranchCompany() instanceof BasicData) {
                        // Get managed instance back
index 28402df84468852790b8e1bb79a378934a38aef6..0fbfe5cef565c2e47ae3e2325c0ec6f6790fc1c0 100644 (file)
@@ -21,10 +21,10 @@ import java.util.Date;
 import java.util.List;
 import javax.ejb.EJB;
 import javax.ejb.Stateless;
+import org.mxchange.jcontacts.model.contact.Contact;
 import org.mxchange.jcontactsbusiness.exceptions.department.DepartmentAlreadyAddedException;
 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;
 import org.mxchange.pizzaapplication.enterprise.BasePizzaEnterpriseBean;
@@ -116,12 +116,12 @@ public class PizzaAdminDepartmentSessionBean extends BasePizzaEnterpriseBean imp
                }
 
                // Is lead employee set?
-               if (department.getDepartmentLead()instanceof Employable) {
-                       // Get managed lead employee
-                       final Employable managedEmployee = this.createManaged(department.getDepartmentLead());
+               if (department.getDepartmentLead() instanceof Contact) {
+                       // Get managed lead contact
+                       final Contact managedContact = this.createManaged(department.getDepartmentLead());
 
                        // Set it back
-                       department.setDepartmentLead(managedEmployee);
+                       department.setDepartmentLead(managedContact);
                }
 
                // Is "owning" user set?
index 79cda542bbedbe26ff7e5d6c9eeba33741e0ff57..86d809caf448bc57dfa43530fcef03e14dafbdec 100644 (file)
@@ -21,6 +21,7 @@ import java.util.Date;
 import java.util.List;
 import javax.ejb.EJB;
 import javax.ejb.Stateless;
+import org.mxchange.jcontacts.model.contact.Contact;
 import org.mxchange.jcontactsbusiness.exceptions.headquarter.HeadquarterAlreadyAddedException;
 import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime;
 import org.mxchange.jcountry.model.data.Country;
@@ -74,6 +75,15 @@ public class PizzaAdminHeadquarterSessionBean extends BasePizzaEnterpriseBean im
                // Add created timestamp
                headquarter.setHeadquarterEntryCreated(new Date());
 
+               // Is contact employee set?
+               if (headquarter.getHeadquarterContactEmployee() instanceof Contact) {
+                       // Get managed lead contact
+                       final Contact managedContact = this.createManaged(headquarter.getHeadquarterContactEmployee());
+
+                       // Set it back
+                       headquarter.setHeadquarterContactEmployee(managedContact);
+               }
+
                // Is user instance set?
                if (headquarter.getHeadquarterUserOwner() instanceof User) {
                        // Get managed instance back