]> git.mxchange.org Git - jfinancials-ejb.git/commitdiff
Please cherry-pick:
authorRoland Häder <roland@mxchange.org>
Sun, 24 Sep 2017 13:34:12 +0000 (15:34 +0200)
committerRoland Häder <roland@mxchange.org>
Sun, 24 Sep 2017 13:34:12 +0000 (15:34 +0200)
- renamed setAllContactPhoneEntriesCreated() -> setAllPhoneEntriesCreated()
- added similar methods for company basic data and branch offices
- also their phone number's created timestamps must be set prior persisting

Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/jcontacts/model/contact/FinancialsAdminContactSessionBean.java
src/java/org/mxchange/jcontactsbusiness/model/basicdata/FinancialsAdminBusinessDataSessionBean.java
src/java/org/mxchange/jcontactsbusiness/model/branchoffice/FinancialsAdminBranchOfficeSessionBean.java
src/java/org/mxchange/jfinancials/database/BaseFinancialsDatabaseBean.java
src/java/org/mxchange/jusercore/model/user/FinancialsAdminUserSessionBean.java

index 9af023551b5c126fcb05a9c558d7089a9cbabee8..b33ae3a5cbcd6ceb198ae4a41766b305f6aa28de 100644 (file)
@@ -67,7 +67,7 @@ public class FinancialsAdminContactSessionBean extends BaseFinancialsDatabaseBea
                contact.setContactCreated(new Date());
 
                // Set all created timestamps, if instance is there
-               this.setAllContactPhoneEntriesCreated(contact);
+               this.setAllPhoneEntriesCreated(contact);
 
                // Persist it
                this.getEntityManager().persist(contact);
index 51b4df2adc8aa3b2070b7f19da51f8616cd74b14..d0a915b5e869a4495f5c8bbac1ac14d7ed130915 100644 (file)
@@ -101,6 +101,9 @@ public class FinancialsAdminBusinessDataSessionBean extends BaseFinancialsDataba
                        basicData.setCompanyContactEmployee(managedEmployee);
                }
 
+               // Set created timestamps for any assigned numbers
+               this.setAllPhoneEntriesCreated(basicData);
+
                // Persist it
                this.getEntityManager().persist(basicData);
 
index 6941efa51a4f255bfe3f2b0ed049dc86523067a8..ad06c114423300cdc793bc158a287543401f4342 100644 (file)
@@ -101,6 +101,9 @@ public class FinancialsAdminBranchOfficeSessionBean extends BaseFinancialsDataba
                        branchOffice.setBranchCountry(managedCountry);
                }
 
+               // Set "created" timestamp on any number assigned
+               this.setAllPhoneEntriesCreated(branchOffice);
+
                // Persist it
                this.getEntityManager().persist(branchOffice);
 
index aa506433442053fdc4b62a9d61c49ddc8670d496..bc03f567d269c175a4706b5f391508cd24a6062e 100644 (file)
@@ -31,6 +31,7 @@ import org.mxchange.jcontacts.model.contact.ContactUtils;
 import org.mxchange.jcontacts.model.contact.UserContact;
 import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData;
 import org.mxchange.jcontactsbusiness.model.basicdata.CompanyBasicData;
+import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice;
 import org.mxchange.jcontactsbusiness.model.employee.CompanyEmployee;
 import org.mxchange.jcontactsbusiness.model.employee.Employee;
 import org.mxchange.jcoreee.database.BaseDatabaseBean;
@@ -274,14 +275,17 @@ public abstract class BaseFinancialsDatabaseBean extends BaseDatabaseBean {
         * <p>
         * @param contact Contact instance to update
         */
-       protected void setAllContactPhoneEntriesCreated (final Contact contact) {
+       protected void setAllPhoneEntriesCreated (final Contact contact) {
                // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("setAllContactPhoneEntriesCreated: contact={0} - CALLED!", contact)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("setAllPhoneEntriesCreated: contact={0} - CALLED!", contact)); //NOI18N
 
                // The contact instance must be valid
                if (null == contact) {
-                       // Throw NPE again
+                       // Throw NPE
                        throw new NullPointerException("contact is null"); //NOI18N
+               } else if (contact.getContactId() != null) {
+                       // Throw IAE
+                       throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is unexpected.", contact.getContactId()));
                }
 
                // Get all phone instances
@@ -290,12 +294,12 @@ public abstract class BaseFinancialsDatabaseBean extends BaseDatabaseBean {
                final DialableMobileNumber mobileNumber = contact.getContactMobileNumber();
 
                // Debug message
-               this.getLoggerBeanLocal().logDebug(MessageFormat.format("setAllContactPhoneEntriesCreated: landLineNumber={0},faxNumber={1},mobileNumber={2}", landLineNumber, faxNumber, mobileNumber)); //NOI18N
+               this.getLoggerBeanLocal().logDebug(MessageFormat.format("setAllPhoneEntriesCreated: landLineNumber={0},faxNumber={1},mobileNumber={2}", landLineNumber, faxNumber, mobileNumber)); //NOI18N
 
                // Is a phone number instance set?
                if ((landLineNumber instanceof DialableLandLineNumber) && (landLineNumber.getPhoneId() == null)) {
                        // Debug message
-                       this.getLoggerBeanLocal().logDebug("setAllContactPhoneEntriesCreated: Setting created timestamp for land-line number ..."); //NOI18N
+                       this.getLoggerBeanLocal().logDebug("setAllPhoneEntriesCreated: Setting created timestamp for land-line number ..."); //NOI18N
 
                        // Set updated timestamp
                        landLineNumber.setPhoneEntryCreated(new Date());
@@ -304,7 +308,7 @@ public abstract class BaseFinancialsDatabaseBean extends BaseDatabaseBean {
                // Is a fax number instance set?
                if ((faxNumber instanceof DialableFaxNumber) && (faxNumber.getPhoneId() == null)) {
                        // Debug message
-                       this.getLoggerBeanLocal().logDebug("setAllContactPhoneEntriesCreated: Setting created timestamp for fax number ..."); //NOI18N
+                       this.getLoggerBeanLocal().logDebug("setAllPhoneEntriesCreated: Setting created timestamp for fax number ..."); //NOI18N
 
                        // Set updated timestamp
                        faxNumber.setPhoneEntryCreated(new Date());
@@ -313,14 +317,114 @@ public abstract class BaseFinancialsDatabaseBean extends BaseDatabaseBean {
                // Is a mobile number instance set?
                if ((mobileNumber instanceof DialableMobileNumber) && (mobileNumber.getPhoneId() == null)) {
                        // Debug message
-                       this.getLoggerBeanLocal().logDebug("setAllContactPhoneEntriesCreated: Setting created timestamp for mobile number ..."); //NOI18N
+                       this.getLoggerBeanLocal().logDebug("setAllPhoneEntriesCreated: Setting created timestamp for mobile number ..."); //NOI18N
 
                        // Set updated timestamp
                        mobileNumber.setPhoneEntryCreated(new Date());
                }
 
                // Trace message
-               this.getLoggerBeanLocal().logTrace("setAllContactPhoneEntriesCreated: EXIT!"); //NOI18N
+               this.getLoggerBeanLocal().logTrace("setAllPhoneEntriesCreated: EXIT!"); //NOI18N
+       }
+
+       /**
+        * Updates all branch office's phone entry's created timestamps
+        * <p>
+        * @param branchOffice Branch office instance to update
+        */
+       protected void setAllPhoneEntriesCreated (final BranchOffice branchOffice) {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("setAllPhoneEntriesCreated: branchOffice={0} - CALLED!", branchOffice)); //NOI18N
+
+               // The contact instance must be valid
+               if (null == branchOffice) {
+                       // Throw NPE again
+                       throw new NullPointerException("branchOffice is null"); //NOI18N
+               } else if (branchOffice.getBranchId() != null) {
+                       // Throw IAE
+                       throw new IllegalArgumentException(MessageFormat.format("branchOffice.branchId={0} is unexpected.", branchOffice.getBranchId()));
+               }
+
+               // Get all phone instances
+               final DialableLandLineNumber landLineNumber = branchOffice.getBranchLandLineNumber();
+               final DialableFaxNumber faxNumber = branchOffice.getBranchFaxNumber();
+
+               // Debug message
+               this.getLoggerBeanLocal().logDebug(MessageFormat.format("setAllPhoneEntriesCreated: landLineNumber={0},faxNumber={1}", landLineNumber, faxNumber)); //NOI18N
+
+               // Is a phone number instance set?
+               if ((landLineNumber instanceof DialableLandLineNumber) && (landLineNumber.getPhoneId() == null)) {
+                       // Debug message
+                       this.getLoggerBeanLocal().logDebug("setAllPhoneEntriesCreated: Setting created timestamp for land-line number ..."); //NOI18N
+
+                       // Set updated timestamp
+                       landLineNumber.setPhoneEntryCreated(new Date());
+               }
+
+               // Is a fax number instance set?
+               if ((faxNumber instanceof DialableFaxNumber) && (faxNumber.getPhoneId() == null)) {
+                       // Debug message
+                       this.getLoggerBeanLocal().logDebug("setAllPhoneEntriesCreated: Setting created timestamp for fax number ..."); //NOI18N
+
+                       // Set updated timestamp
+                       faxNumber.setPhoneEntryCreated(new Date());
+               }
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace("setAllPhoneEntriesCreated: EXIT!"); //NOI18N
+       }
+
+       /**
+        * Updates all company's phone entry's created timestamps
+        * <p>
+        * @param basicData Company basic data instance to update
+        */
+       protected void setAllPhoneEntriesCreated (final BusinessBasicData basicData) {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("setAllPhoneEntriesCreated: basicData={0} - CALLED!", basicData)); //NOI18N
+
+               // The contact instance must be valid
+               if (null == basicData) {
+                       // Throw NPE again
+                       throw new NullPointerException("basicData is null"); //NOI18N
+               } else if (basicData.getBasicDataId() != null) {
+                       // Throw IAE
+                       throw new IllegalArgumentException(MessageFormat.format("basicData.basicDataId={0} is unexpected.", basicData.getBasicDataId()));
+               }
+
+               // Get all phone instances
+               final DialableLandLineNumber landLineNumber = basicData.getCompanyLandLineNumber();
+               final DialableFaxNumber faxNumber = basicData.getCompanyFaxNumber();
+
+               // Debug message
+               this.getLoggerBeanLocal().logDebug(MessageFormat.format("setAllPhoneEntriesCreated: landLineNumber={0},faxNumber={1}", landLineNumber, faxNumber)); //NOI18N
+
+               // Is a phone number instance set?
+               if ((landLineNumber instanceof DialableLandLineNumber) && (landLineNumber.getPhoneId() == null)) {
+                       // Debug message
+                       this.getLoggerBeanLocal().logDebug("setAllPhoneEntriesCreated: Setting created timestamp for land-line number ..."); //NOI18N
+
+                       // Set updated timestamp
+                       landLineNumber.setPhoneEntryCreated(new Date());
+
+                       // Set it back in basic data
+                       basicData.setCompanyLandLineNumber(landLineNumber);
+               }
+
+               // Is a fax number instance set?
+               if ((faxNumber instanceof DialableFaxNumber) && (faxNumber.getPhoneId() == null)) {
+                       // Debug message
+                       this.getLoggerBeanLocal().logDebug("setAllPhoneEntriesCreated: Setting created timestamp for fax number ..."); //NOI18N
+
+                       // Set updated timestamp
+                       faxNumber.setPhoneEntryCreated(new Date());
+
+                       // Set it back in basic data
+                       basicData.setCompanyFaxNumber(faxNumber);
+               }
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace("setAllPhoneEntriesCreated: EXIT!"); //NOI18N
        }
 
        /**
index 550242e8080779529797ce812201e21836c007d7..3460b43c6f3157ecfc4f29942f105c9226d86dde 100644 (file)
@@ -85,7 +85,7 @@ public class FinancialsAdminUserSessionBean extends BaseFinancialsDatabaseBean i
                user.getUserContact().setContactCreated(new Date());
 
                // Update mobile, land-line and fax instance
-               this.setAllContactPhoneEntriesCreated(user.getUserContact());
+               this.setAllPhoneEntriesCreated(user.getUserContact());
 
                // Persist it
                this.getEntityManager().persist(user);