]> git.mxchange.org Git - jfinancials-war.git/commitdiff
Please cherry-pick:
authorRoland Häder <roland@mxchange.org>
Thu, 20 Oct 2022 17:17:46 +0000 (19:17 +0200)
committerRoland Häder <roland@mxchange.org>
Thu, 20 Oct 2022 17:17:46 +0000 (19:17 +0200)
- added missing parameter "country" for updated constructor
- also validated if contact's Country instance is set and already persisted

src/java/org/mxchange/jfinancials/beans/contact/FinancialsAdminContactWebRequestBean.java
src/java/org/mxchange/jfinancials/beans/contact/FinancialsContactWebRequestBean.java
web/admin/contact/admin_contact_list.xhtml

index 5e12ea7ae79d22e76eefee4f01d4fb0354df89b8..b4b2fbc7b65bf23c37bf078880fcb58c11b476c8 100644 (file)
@@ -38,9 +38,9 @@ import org.mxchange.jcontacts.exceptions.ContactNotFoundException;
 import org.mxchange.jcontacts.model.contact.AdminContactSessionBeanRemote;
 import org.mxchange.jcontacts.model.contact.Contact;
 import org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote;
-import org.mxchange.jcontacts.model.utils.ContactUtils;
 import org.mxchange.jcontacts.model.contact.UserContact;
 import org.mxchange.jcontacts.model.contact.title.PersonalTitle;
+import org.mxchange.jcontacts.model.utils.ContactUtils;
 import org.mxchange.jcountry.model.data.Country;
 import org.mxchange.jfinancials.beans.BaseFinancialsBean;
 import org.mxchange.jfinancials.beans.contact.list.FinancialsContactListWebViewController;
@@ -190,7 +190,7 @@ public class FinancialsAdminContactWebRequestBean extends BaseFinancialsBean imp
        private boolean isLandLineUnlinked;
 
        /**
-        * Whether a cmobile entry has been unlinked
+        * Whether a mobile entry has been unlinked
         */
        private boolean isMobileNumberUnlinked;
 
@@ -405,6 +405,15 @@ public class FinancialsAdminContactWebRequestBean extends BaseFinancialsBean imp
                } else if (this.getFamilyName().isEmpty()) {
                        // Empty string
                        throw new IllegalStateException("familyName is empty"); //NOI18N
+               } else if (this.getContactCountry() == null) {
+                       // Throw NPE
+                       throw new NullPointerException("contactCountry is null"); //NOI18N
+               } else if (this.getContactCountry().getCountryId() == null) {
+                       // Throw it again
+                       throw new NullPointerException("contactCountry.countryId is null"); //NOI18N
+               } else if (this.getContactCountry().getCountryId() < 1) {
+                       // Throw IAE
+                       throw new IllegalArgumentException(MessageFormat.format("contactCountry.countryId={0} is invalid", this.getContactCountry().getCountryId())); //NOI18N
                }
 
                // Generate phone number
@@ -434,14 +443,14 @@ public class FinancialsAdminContactWebRequestBean extends BaseFinancialsBean imp
                final Contact localContact = new UserContact(
                                          this.getPersonalTitle(),
                                          this.getFirstName(),
-                                         this.getFamilyName()
+                                         this.getFamilyName(),
+                                         this.getContactCountry()
                          );
 
                // Add all others
                localContact.setContactBirthday(this.getBirthday());
                localContact.setContactCity(this.getCity());
                localContact.setContactComment(this.getComment());
-               localContact.setContactCountry(this.getContactCountry());
                localContact.setContactEmailAddress(this.getEmailAddress());
                localContact.setContactHouseNumber(this.getHouseNumber());
                localContact.setContactId(this.getContactId());
@@ -449,9 +458,6 @@ public class FinancialsAdminContactWebRequestBean extends BaseFinancialsBean imp
                localContact.setContactTitle(this.getAcademicTitle());
                localContact.setContactZipCode(this.getZipCode());
 
-               // Set ownContact
-               localContact.setContactOwnContact(Boolean.TRUE);
-
                // Don't set null or wrong references
                if ((landLine instanceof DialableLandLineNumber) && (landLine.getPhoneCountry() instanceof Country) && (this.getLandLineAreaCode() != null) && (this.getLandLineNumber() != null) && (this.getLandLineAreaCode() > 0) && (this.getLandLineNumber() > 0)) {
                        // Now the number must be given
index 6ea9a99650e4f8e5229d7150aaf18376e18da70b..21024af8ce9514e41810b485e7e92c00c5f6c0ad 100644 (file)
@@ -33,9 +33,9 @@ import org.mxchange.jcontacts.events.contact.update.UpdatedContactEvent;
 import org.mxchange.jcontacts.exceptions.ContactNotFoundException;
 import org.mxchange.jcontacts.model.contact.Contact;
 import org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote;
-import org.mxchange.jcontacts.model.utils.ContactUtils;
 import org.mxchange.jcontacts.model.contact.UserContact;
 import org.mxchange.jcontacts.model.contact.title.PersonalTitle;
+import org.mxchange.jcontacts.model.utils.ContactUtils;
 import org.mxchange.jcountry.model.data.Country;
 import org.mxchange.jfinancials.beans.BaseFinancialsBean;
 import org.mxchange.jfinancials.beans.contact.list.FinancialsContactListWebViewController;
@@ -330,7 +330,8 @@ public class FinancialsContactWebRequestBean extends BaseFinancialsBean implemen
                final Contact contact = new UserContact(
                                          this.getPersonalTitle(),
                                          this.getFirstName(),
-                                         this.getFamilyName()
+                                         this.getFamilyName(),
+                                         this.getCountry()
                          );
 
                // Return instance
index cc23c1196cca68e4d6845a575bf139ef9f9c858c..decc2a8a1dee2b542483835aee743485e49a20d1 100644 (file)
                                                        type="reset"
                                                        value="#{msg.BUTTON_RESET_FORM}"
                                                        />
+
                                                <p:commandButton
                                                        type="submit"
                                                        value="#{msg.BUTTON_ADMIN_ADD_CONTACT}"