]> git.mxchange.org Git - jjobs-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:18:49 +0000 (19:18 +0200)
- added missing parameter "country" for updated constructor
- also validated if contact's Country instance is set and already persisted

src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java
src/java/org/mxchange/jjobs/beans/contact/JobsContactWebRequestBean.java
web/admin/contact/admin_contact_list.xhtml

index ab6f1db2dd4b6dd1eafbf814c42901b1db954e68..1b52b855744f96829bd1a9cb0a5ba5e9d53d1bcf 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.jjobs.beans.BaseJobsBean;
 import org.mxchange.jjobs.beans.contact.list.JobsContactListWebViewController;
@@ -196,7 +196,7 @@ public class JobsAdminContactWebRequestBean extends BaseJobsBean implements Jobs
        private boolean isLandLineUnlinked;
 
        /**
-        * Whether a cmobile entry has been unlinked
+        * Whether a mobile entry has been unlinked
         */
        private boolean isMobileNumberUnlinked;
 
@@ -411,6 +411,15 @@ public class JobsAdminContactWebRequestBean extends BaseJobsBean implements Jobs
                } 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
@@ -440,14 +449,14 @@ public class JobsAdminContactWebRequestBean extends BaseJobsBean implements Jobs
                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());
@@ -455,9 +464,6 @@ public class JobsAdminContactWebRequestBean extends BaseJobsBean implements Jobs
                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 867e93e75a95bd5e7265c89a1422082e40625e92..2b8415c33da2178bb69cba0bff817128b49469ee 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.jjobs.beans.BaseJobsBean;
 import org.mxchange.jjobs.beans.contact.list.JobsContactListWebViewController;
@@ -330,7 +330,8 @@ public class JobsContactWebRequestBean extends BaseJobsBean implements JobsConta
                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}"