From: Roland Häder Date: Wed, 20 Apr 2016 15:09:16 +0000 (+0200) Subject: Continued a bit: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=dd2fa8d118553ac4d659be56dc43c9fecfef05bc;p=pizzaservice-war.git Continued a bit: - All optional data is now checked with "instanceof" - added logging messages (direct output) - maybe put the copy command here? (was not called) - ignored strings for i18n Signed-off-by: Roland Häder --- diff --git a/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaAdminContactWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaAdminContactWebRequestBean.java index a7f3822b..565358b5 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaAdminContactWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaAdminContactWebRequestBean.java @@ -33,6 +33,9 @@ import org.mxchange.jcontacts.contact.ContactSessionBeanRemote; import org.mxchange.jcontacts.contact.gender.Gender; import org.mxchange.jcontacts.events.contact.AdminAddedContactEvent; import org.mxchange.jcountry.data.Country; +import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber; +import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber; +import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber; import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider; /** @@ -198,13 +201,16 @@ public class PizzaAdminContactWebRequestBean implements PizzaAdminContactWebRequ @Override public void copyContactToController (final Contact contact) { + // Log message + System.out.println(MessageFormat.format("AdminContactController::copyContactToController(): contact={0} - CALLED!", contact)); //NOI18N + // The contact instance must be valid if (null == contact) { // Throw NPE again - throw new NullPointerException("this.user.userContact is null"); + throw new NullPointerException("this.user.userContact is null"); //NOI18N } else if (contact.getContactId() < 1) { // Not valid - throw new IllegalStateException(MessageFormat.format("this.user.userContact.contactId={0} is not valid.", contact.getContactId())); + throw new IllegalStateException(MessageFormat.format("this.user.userContact.contactId={0} is not valid.", contact.getContactId())); //NOI18N } // Set all fields: contact @@ -221,22 +227,34 @@ public class PizzaAdminContactWebRequestBean implements PizzaAdminContactWebRequ this.setStreet(contact.getContactStreet()); this.setZipCode(contact.getContactZipCode()); - // ... cellphone data - this.setCellphoneId(contact.getContactCellphoneNumber().getPhoneId()); - this.setCellphoneCarrier(contact.getContactCellphoneNumber().getCellphoneProvider()); - this.setCellphoneNumber(contact.getContactCellphoneNumber().getPhoneNumber()); - - // ... fax data - this.setFaxId(contact.getContactFaxNumber().getPhoneId()); - this.setFaxAreaCode(contact.getContactFaxNumber().getPhoneAreaCode()); - this.setFaxCountry(contact.getContactFaxNumber().getPhoneCountry()); - this.setFaxNumber(contact.getContactFaxNumber().getPhoneNumber()); - - // .. land-line data - this.setLandLineId(contact.getContactLandLineNumber().getPhoneId()); - this.setPhoneAreaCode(contact.getContactLandLineNumber().getPhoneAreaCode()); - this.setPhoneCountry(contact.getContactLandLineNumber().getPhoneCountry()); - this.setPhoneNumber(contact.getContactLandLineNumber().getPhoneNumber()); + // Is the cell phone set? + if (contact.getContactCellphoneNumber() instanceof DialableCellphoneNumber) { + // ... cellphone data + this.setCellphoneId(contact.getContactCellphoneNumber().getPhoneId()); + this.setCellphoneCarrier(contact.getContactCellphoneNumber().getCellphoneProvider()); + this.setCellphoneNumber(contact.getContactCellphoneNumber().getPhoneNumber()); + } + + // Is the fax set? + if (contact.getContactFaxNumber() instanceof DialableFaxNumber) { + // ... fax data + this.setFaxId(contact.getContactFaxNumber().getPhoneId()); + this.setFaxAreaCode(contact.getContactFaxNumber().getPhoneAreaCode()); + this.setFaxCountry(contact.getContactFaxNumber().getPhoneCountry()); + this.setFaxNumber(contact.getContactFaxNumber().getPhoneNumber()); + } + + // Is the land-line number set? + if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) { + // .. land-line data + this.setLandLineId(contact.getContactLandLineNumber().getPhoneId()); + this.setPhoneAreaCode(contact.getContactLandLineNumber().getPhoneAreaCode()); + this.setPhoneCountry(contact.getContactLandLineNumber().getPhoneCountry()); + this.setPhoneNumber(contact.getContactLandLineNumber().getPhoneNumber()); + } + + // Log message + System.out.println("AdminContactController::copyContactToController(): EXIT!"); //NOI18N } @Override diff --git a/src/java/org/mxchange/pizzaapplication/beans/helper/PizzaAdminWebRequestHelper.java b/src/java/org/mxchange/pizzaapplication/beans/helper/PizzaAdminWebRequestHelper.java index fe347eea..4ca5964e 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/helper/PizzaAdminWebRequestHelper.java +++ b/src/java/org/mxchange/pizzaapplication/beans/helper/PizzaAdminWebRequestHelper.java @@ -21,8 +21,8 @@ import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import javax.inject.Named; import org.mxchange.jcontacts.contact.Contact; -import org.mxchange.pizzaapplication.beans.contact.PizzaAdminContactWebRequestController; import org.mxchange.jusercore.model.user.User; +import org.mxchange.pizzaapplication.beans.contact.PizzaAdminContactWebRequestController; import org.mxchange.pizzaapplication.beans.user.PizzaAdminUserWebRequestController; /** @@ -64,16 +64,19 @@ public class PizzaAdminWebRequestHelper implements PizzaAdminWebRequestControlle @Override public void copyUserToController () { + // Log message + System.out.println("AdminHelper::copyUserToController - CALLED!"); //NOI18N + // Validate user instance if (this.getUser() == null) { // Throw NPE - throw new NullPointerException("this.user is null"); + throw new NullPointerException("this.user is null"); //NOI18N } else if (this.getUser().getUserId() == null) { // Throw NPE again - throw new NullPointerException("this.user.userId is null"); + throw new NullPointerException("this.user.userId is null"); //NOI18N } else if (this.getUser().getUserId() < 1) { // Not valid - throw new IllegalStateException(MessageFormat.format("this.user.userId={0} is not valid.", this.getUser().getUserId())); + throw new IllegalStateException(MessageFormat.format("this.user.userId={0} is not valid.", this.getUser().getUserId())); //NOI18N } // Set all fields: user @@ -84,6 +87,9 @@ public class PizzaAdminWebRequestHelper implements PizzaAdminWebRequestControlle // Call contact controller this.adminContactController.copyContactToController(contact); + + // Log message + System.out.println("AdminHelper::copyUserToController - EXIT!"); //NOI18N } @Override diff --git a/web/admin/user/admin_user_edit.xhtml b/web/admin/user/admin_user_edit.xhtml index 123924a4..ebf3e1b6 100644 --- a/web/admin/user/admin_user_edit.xhtml +++ b/web/admin/user/admin_user_edit.xhtml @@ -10,6 +10,7 @@ + @@ -23,9 +24,6 @@ - - -