]> git.mxchange.org Git - jjobs-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:24:39 +0000 (19:24 +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/JobsAdminBranchOfficeSessionBean.java
src/java/org/mxchange/jcontactsbusiness/model/department/JobsAdminDepartmentSessionBean.java
src/java/org/mxchange/jcontactsbusiness/model/headquarter/JobsAdminHeadquarterSessionBean.java

index 7ea449febb78fe5b7196004694c613b4609a03b8..baf8451494cdb8b2c4695d60013481f7d0423075 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;
@@ -75,6 +76,24 @@ public class JobsAdminBranchOfficeSessionBean extends BaseJobsEnterpriseBean imp
                // 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 5b91505aa60ae5346cefa22f75144c3e4742e6d0..1177579a61851f0d282dbb2426ca42bce509d179 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.jjobs.enterprise.BaseJobsEnterpriseBean;
 import org.mxchange.jusercore.model.user.User;
@@ -116,12 +116,12 @@ public class JobsAdminDepartmentSessionBean extends BaseJobsEnterpriseBean imple
                }
 
                // 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 a0d3561341cfeed3d3fc39a123c1ed7c23ca48c1..4a509c25a898b311933b19687a15269a63064b80 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 JobsAdminHeadquarterSessionBean extends BaseJobsEnterpriseBean impl
                // 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