]> git.mxchange.org Git - addressbook-ejb.git/commitdiff
used new setter instead of "hard-coded"
authorRoland Häder <roland@mxchange.org>
Mon, 2 May 2016 15:26:37 +0000 (17:26 +0200)
committerRoland Haeder <roland@mxchange.org>
Mon, 2 May 2016 19:55:46 +0000 (21:55 +0200)
Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/jusercore/model/user/AddressbookUserSessionBean.java

index ad2233916df38233b17e9e0eeff5d4e053bdcc9c..7a53af4037869b08a3575f3cbd7bd4d3dfcca865 100644 (file)
@@ -25,8 +25,8 @@ import javax.ejb.Stateless;
 import javax.persistence.NoResultException;
 import javax.persistence.PersistenceException;
 import javax.persistence.Query;
+import org.mxchange.addressbook.database.BaseAddressbookDatabaseBean;
 import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jcoreee.database.BaseDatabaseBean;
 import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber;
 import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
 import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
@@ -43,7 +43,7 @@ import org.mxchange.jusercore.model.user.status.UserAccountStatus;
  * @author Roland Haeder<roland@mxchange.org>
  */
 @Stateless (name = "user", description = "A bean handling the user data")
-public class AddressbookUserSessionBean extends BaseDatabaseBean implements UserSessionBeanRemote {
+public class AddressbookUserSessionBean extends BaseAddressbookDatabaseBean implements UserSessionBeanRemote {
 
        /**
         * Serial number
@@ -89,28 +89,8 @@ public class AddressbookUserSessionBean extends BaseDatabaseBean implements User
                user.setUserCreated(new GregorianCalendar());
                user.getUserContact().setContactCreated(new GregorianCalendar());
 
-               // Get all phone instances
-               DialableLandLineNumber landLineNumber = user.getUserContact().getContactLandLineNumber();
-               DialableFaxNumber faxNumber = user.getUserContact().getContactFaxNumber();
-               DialableCellphoneNumber cellphoneNumber = user.getUserContact().getContactCellphoneNumber();
-
-               // Is a phone number instance set?
-               if (landLineNumber instanceof DialableLandLineNumber) {
-                       // Set created timestamp
-                       landLineNumber.setPhoneEntryCreated(new GregorianCalendar());
-               }
-
-               // Is a fax number instance set?
-               if (faxNumber instanceof DialableFaxNumber) {
-                       // Set created timestamp
-                       faxNumber.setPhoneEntryCreated(new GregorianCalendar());
-               }
-
-               // Is a mobile number instance set?
-               if (cellphoneNumber instanceof DialableCellphoneNumber) {
-                       // Set created timestamp
-                       cellphoneNumber.setPhoneEntryCreated(new GregorianCalendar());
-               }
+               // Update cellphone, land-line and fax instance
+               this.setAllContactPhoneEntriesCreated(user.getUserContact());
 
                        // Persist it
                this.getEntityManager().persist(user);