]> git.mxchange.org Git - addressbook-ejb.git/blobdiff - src/java/org/mxchange/jcontactsbusiness/model/headquarter/AddressbookAdminHeadquarterSessionBean.java
Don't cherry-pick:
[addressbook-ejb.git] / src / java / org / mxchange / jcontactsbusiness / model / headquarter / AddressbookAdminHeadquarterSessionBean.java
index cc7738a4fdfd4a659985c81447aa190a2c50a668..2718e0a6066931b92ad6f29a741d0d1565748fd6 100644 (file)
@@ -21,10 +21,12 @@ import java.util.Date;
 import java.util.List;
 import javax.ejb.EJB;
 import javax.ejb.Stateless;
+import org.mxchange.addressbook.enterprise.BaseAddressbookEnterpriseBean;
+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.jcontactsbusiness.model.utils.HeadquarterUtils;
 import org.mxchange.jcountry.model.data.Country;
-import org.mxchange.addressbook.enterprise.BaseAddressbookEnterpriseBean;
 import org.mxchange.jusercore.model.user.User;
 
 /**
@@ -72,7 +74,16 @@ public class AddressbookAdminHeadquarterSessionBean extends BaseAddressbookEnter
                }
 
                // Add created timestamp
-               headquarter.setHeadquarterCreated(new Date());
+               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) {
@@ -139,7 +150,7 @@ public class AddressbookAdminHeadquarterSessionBean extends BaseAddressbookEnter
                // Check all single addresses
                for (final Headquarter hq : headquarters) {
                        // Is the same address found?
-                       if (Headquarters.isSameAddress(hq, headquarter)) {
+                       if (HeadquarterUtils.isSameAddress(hq, headquarter)) {
                                // Found one
                                isFound = true;
                                break;