]> git.mxchange.org Git - jfinancials-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>
Mon, 11 May 2020 00:48:27 +0000 (02:48 +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/FinancialsAdminBranchOfficeSessionBean.java
src/java/org/mxchange/jcontactsbusiness/model/department/FinancialsAdminDepartmentSessionBean.java
src/java/org/mxchange/jcontactsbusiness/model/headquarter/FinancialsAdminHeadquarterSessionBean.java

index 8be5c1de593322c180094455a72695a34fc244fe..2bf35bccd91c4eba08c59e13446c910e2a94ddda 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.exceptions.branchoffice.BranchOfficeNotFoundException;
 import org.mxchange.jcontactsbusiness.model.basicdata.BasicData;
@@ -76,6 +77,24 @@ public class FinancialsAdminBranchOfficeSessionBean extends BaseFinancialsEnterp
                // 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 ef70d30849faf0b5ad4deee0f1d90f7e9b69b2e3..ac304eb4ed5991e3a178b4dea688c2c072bb6d15 100644 (file)
@@ -21,11 +21,11 @@ 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.exceptions.department.DepartmentNotFoundException;
 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.jfinancials.enterprise.BaseFinancialsEnterpriseBean;
 import org.mxchange.jusercore.model.user.User;
@@ -117,12 +117,12 @@ public class FinancialsAdminDepartmentSessionBean extends BaseFinancialsEnterpri
                }
 
                // 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 4fdb4d183b291a0794f2f22d7aa24156187558d7..55c9d7ef1e67977cf4af2c58d087b37c00d06ca2 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 FinancialsAdminHeadquarterSessionBean extends BaseFinancialsEnterpr
                // 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