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

lib/jcontacts-core.jar
src/java/org/mxchange/pizzaapplication/beans/contact/PizzaAdminContactWebRequestBean.java
src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebRequestBean.java
web/admin/contact/admin_contact_list.xhtml

index 14ab378f90ce45eff5815f34d37ebb7bd1d249e8..a30c9f085494b4d59401bd0375883808bbf39d14 100644 (file)
Binary files a/lib/jcontacts-core.jar and b/lib/jcontacts-core.jar differ
index c956ab1bfc5c62dc65f471d6e18a29499b1ae840..b5f5382cdcd8e4d0aca983108195d289904d5011 100644 (file)
@@ -36,9 +36,9 @@ import org.mxchange.jcontacts.exceptions.ContactAlreadyAddedException;
 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.contact.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.jphone.model.phonenumbers.DialableNumber;
 import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
@@ -175,7 +175,7 @@ public class PizzaAdminContactWebRequestBean extends BasePizzaBean implements Pi
        private boolean isLandLineUnlinked;
 
        /**
-        * Whether a cmobile entry has been unlinked
+        * Whether a mobile entry has been unlinked
         */
        private boolean isMobileNumberUnlinked;
 
@@ -392,6 +392,15 @@ public class PizzaAdminContactWebRequestBean extends BasePizzaBean implements Pi
                } 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
@@ -408,20 +417,24 @@ public class PizzaAdminContactWebRequestBean extends BasePizzaBean implements Pi
                        contact.setContactId(this.getContactId());
                }
 
-               // Add all others
-               contact.setContactTitle(this.getAcademicTitle());
-               contact.setContactBirthday(this.getBirthday());
-               contact.setContactStreet(this.getStreet());
-               contact.setContactHouseNumber(this.getHouseNumber());
-               contact.setContactZipCode(this.getZipCode());
-               contact.setContactCity(this.getCity());
-               contact.setContactCountry(this.getContactCountry());
-               contact.setContactEmailAddress(this.getEmailAddress());
-               contact.setContactBirthday(this.getBirthday());
-               contact.setContactComment(this.getComment());
+               // Create new instance
+               final Contact localContact = new UserContact(
+                                         this.getPersonalTitle(),
+                                         this.getFirstName(),
+                                         this.getFamilyName(),
+                                         this.getContactCountry()
+                         );
 
-               // Set ownContact
-               contact.setContactOwnContact(Boolean.TRUE);
+               // Add all others
+               localContact.setContactBirthday(this.getBirthday());
+               localContact.setContactCity(this.getCity());
+               localContact.setContactComment(this.getComment());
+               localContact.setContactEmailAddress(this.getEmailAddress());
+               localContact.setContactHouseNumber(this.getHouseNumber());
+               localContact.setContactId(this.getContactId());
+               localContact.setContactStreet(this.getStreet());
+               localContact.setContactTitle(this.getAcademicTitle());
+               localContact.setContactZipCode(this.getZipCode());
 
                // 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)) {
index 79f52d47b02d206e88dcc172ed91f6f643ae3624..5ec23a3dab22fe9ada252733655a264c601b7b01 100644 (file)
@@ -35,9 +35,9 @@ import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEven
 import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent;
 import org.mxchange.jcontacts.model.contact.Contact;
 import org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote;
-import org.mxchange.jcontacts.model.contact.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.jphone.model.phonenumbers.fax.DialableFaxNumber;
 import org.mxchange.jphone.model.phonenumbers.fax.FaxNumber;
@@ -493,37 +493,12 @@ public class PizzaContactWebRequestBean extends BasePizzaBean implements PizzaCo
                DialableFaxNumber fax = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
 
                // Create new contact
-               Contact contact = new UserContact(this.getPersonalTitle(), this.getFirstName(), this.getFamilyName());
-               contact.setContactStreet(this.getStreet());
-               contact.setContactHouseNumber(this.getHouseNumber());
-               contact.setContactHouseNumberExtension(this.getHouseNumberExtension());
-               contact.setContactZipCode(this.getZipCode());
-               contact.setContactCity(this.getCity());
-               contact.setContactCountry(this.getCountry());
-               contact.setContactEmailAddress(this.getEmailAddress());
-               contact.setContactBirthday(this.getBirthday());
-               contact.setContactComment(this.getComment());
-
-               // Don't set null or wrong references
-               if ((phone instanceof DialableLandLineNumber) && (phone.getPhoneCountry() instanceof Country) && (this.getLandLineAreaCode() != null) && (this.getLandLineNumber() != null) && (this.getLandLineAreaCode() > 0) && (this.getLandLineNumber() > 0)) {
-                       // Now the number must be given
-                       if (phone.getPhoneAreaCode() == null) {
-                               // Is null
-                               throw new NullPointerException("phone.phoneAreaCode is null"); //NOI18N
-                       } else if (phone.getPhoneAreaCode() < 1) {
-                               // Abort here
-                               throw new IllegalArgumentException("phone.phoneAreaCode is zero or below."); //NOI18N
-                       } else if (phone.getPhoneNumber() == null) {
-                               // Is null
-                               throw new NullPointerException("phone.phoneNumber is null"); //NOI18N
-                       } else if (phone.getPhoneNumber() < 1) {
-                               // Abort here
-                               throw new IllegalArgumentException("phone.phoneNumber is zero or below."); //NOI18N
-                       }
-
-                       // Set phone number
-                       contact.setContactLandLineNumber(phone);
-               }
+               final Contact contact = new UserContact(
+                                         this.getPersonalTitle(),
+                                         this.getFirstName(),
+                                         this.getFamilyName(),
+                                         this.getCountry()
+                         );
 
                // Don't set null or wrong references
                if ((fax instanceof DialableFaxNumber) && (fax.getPhoneCountry() instanceof Country) && (this.getFaxAreaCode() != null) && (this.getFaxNumber() != null) && (this.getFaxAreaCode() > 0) && (this.getFaxNumber() > 0)) {
index 855fdc21c79cd9ab5550d05c7af54e36b67c4d2e..0d8e32ee0dd88c62b9dce33e8fd8eb0572a430ab 100644 (file)
 
                                <widgets:outputAdminContactDataFormFields />
 
+<<<<<<< HEAD
                                <div class="table-footer">
                                        <p:commandButton styleClass="reset divider-right" type="reset" value="#{msg.BUTTON_RESET_FORM}" />
                                        <p:commandButton styleClass="submit" type="submit" id="button_add_contact" value="#{msg.BUTTON_ADMIN_ADD_CONTACT}" action="#{adminContactController.addContact()}" />
                                </div>
                        </h:panelGroup>
+=======
+                               <f:facet name="footer">
+                                       <p:panelGrid columns="2" layout="grid">
+                                               <p:commandButton
+                                                       styleClass="reset"
+                                                       type="reset"
+                                                       value="#{msg.BUTTON_RESET_FORM}"
+                                                       />
+
+                                               <p:commandButton
+                                                       type="submit"
+                                                       value="#{msg.BUTTON_ADMIN_ADD_CONTACT}"
+                                                       action="#{adminContactController.addContact()}"
+                                                       update="form-list-contacts:contactList"
+                                                       />
+                                       </p:panelGrid>
+                               </f:facet>
+                       </p:panelGrid>
+>>>>>>> 2b3f1b133 (Please cherry-pick:)
                </h:form>
        </ui:define>
 </ui:composition>