From 13c2afc2065d2b528dabdde7cd744020dc323b1a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 17 Aug 2016 17:06:28 +0200 Subject: [PATCH] Please cherry-pick: - fixed wrong copyFooToController() method for fax/land-line - and implemented those missing methods --- .../helper/JobsWebRequestController.java | 12 ++- .../beans/helper/JobsWebRequestHelper.java | 80 +++++++++++++++++++ web/admin/fax/admin_fax_edit.xhtml | 2 +- web/admin/landline/admin_landline_edit.xhtml | 2 +- 4 files changed, 93 insertions(+), 3 deletions(-) diff --git a/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestController.java b/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestController.java index bc7b7f59..538211a5 100644 --- a/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestController.java +++ b/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestController.java @@ -31,7 +31,17 @@ import org.mxchange.jusercore.model.user.User; public interface JobsWebRequestController extends Serializable { /** - * Copies currently set mobile instance's data to admin phone controller + * Copies currently set fax number's data to admin phone controller + */ + void copyFaxNumberToController (); + + /** + * Copies currently set land-line number's data to admin phone controller + */ + void copyLandLineNumberToController (); + + /** + * Copies currently set mobile number's data to admin phone controller */ void copyMobileNumberToController (); diff --git a/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelper.java b/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelper.java index 85acc7ed..32393096 100644 --- a/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelper.java +++ b/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelper.java @@ -113,6 +113,86 @@ public class JobsWebRequestHelper implements JobsWebRequestController { this.adminContactController.copyContactToController(this.getContact()); } + @Override + public void copyFaxNumberToController () { + // Validate fax instance + if (this.getFaxNumber() == null) { + // Throw NPE + throw new NullPointerException("this.faxNumber is null"); + } else if (this.getFaxNumber().getPhoneId() == null) { + // Throw again + throw new NullPointerException("this.faxNumber.phoneId is null"); + } else if (this.getFaxNumber().getPhoneId() < 1) { + // Invalid id number + throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneId={0} is not valid", this.getFaxNumber().getPhoneId())); + } else if (this.getFaxNumber().getPhoneAreaCode()== null) { + // Throw again + throw new NullPointerException("this.faxNumber.phoneAreaCode is null"); + } else if (this.getFaxNumber().getPhoneAreaCode() < 1) { + // Invalid id number + throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneAreaCode={0} is not valid", this.getFaxNumber().getPhoneAreaCode())); + } else if (this.getFaxNumber().getPhoneCountry() == null) { + // Throw NPE again + throw new NullPointerException("this.faxNumber.phoneCountry is null"); + } else if (this.getFaxNumber().getPhoneCountry().getCountryId() == null) { + // ... throw again + throw new NullPointerException("this.faxNumber.phoneCountry.countryId is null"); + } else if (this.getFaxNumber().getPhoneCountry().getCountryId() < 1) { + // Invalid id + throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneCountry.countryId={0} is invalid", this.getFaxNumber().getPhoneCountry().getCountryId())); + } else if (this.getFaxNumber().getPhoneNumber() == null) { + // Throw NPE again ... + throw new NullPointerException("this.faxNumber.phoneNumber is null"); + } else if (this.getFaxNumber().getPhoneNumber() < 1) { + // Invalid id number + throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneNumber={0} is not valid", this.getFaxNumber().getPhoneNumber())); + } + + // Copy all (changeable) data fields to admin controller + this.adminPhoneController.setPhoneCountry(this.getFaxNumber().getPhoneCountry()); + this.adminPhoneController.setPhoneNumber(this.getFaxNumber().getPhoneNumber()); + } + + @Override + public void copyLandLineNumberToController () { + // Validate land-line instance + if (this.getLandLineNumber() == null) { + // Throw NPE + throw new NullPointerException("this.landLineNumber is null"); + } else if (this.getLandLineNumber().getPhoneId() == null) { + // Throw again + throw new NullPointerException("this.landLineNumber.phoneId is null"); + } else if (this.getLandLineNumber().getPhoneId() < 1) { + // Invalid id number + throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneId={0} is not valid", this.getLandLineNumber().getPhoneId())); + } else if (this.getFaxNumber().getPhoneAreaCode()== null) { + // Throw again + throw new NullPointerException("this.landLineNumber.phoneAreaCode is null"); + } else if (this.getFaxNumber().getPhoneAreaCode() < 1) { + // Invalid id number + throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneAreaCode={0} is not valid", this.getFaxNumber().getPhoneAreaCode())); + } else if (this.getLandLineNumber().getPhoneCountry() == null) { + // Throw NPE again + throw new NullPointerException("this.landLineNumber.phoneCountry is null"); + } else if (this.getLandLineNumber().getPhoneCountry().getCountryId() == null) { + // ... throw again + throw new NullPointerException("this.landLineNumber.phoneCountry.countryId is null"); + } else if (this.getLandLineNumber().getPhoneCountry().getCountryId() < 1) { + // Invalid id + throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneCountry.countryId={0} is invalid", this.getLandLineNumber().getPhoneCountry().getCountryId())); + } else if (this.getLandLineNumber().getPhoneNumber() == null) { + // Throw NPE again ... + throw new NullPointerException("this.landLineNumber.phoneNumber is null"); + } else if (this.getLandLineNumber().getPhoneNumber() < 1) { + // Invalid id number + throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneNumber={0} is not valid", this.getLandLineNumber().getPhoneNumber())); + } + + // Copy all (changeable) data fields to admin controller + this.adminPhoneController.setPhoneCountry(this.getLandLineNumber().getPhoneCountry()); + this.adminPhoneController.setPhoneNumber(this.getLandLineNumber().getPhoneNumber()); + } + @Override public void copyMobileNumberToController () { // Validate mobile instance diff --git a/web/admin/fax/admin_fax_edit.xhtml b/web/admin/fax/admin_fax_edit.xhtml index af133657..c700ac1c 100644 --- a/web/admin/fax/admin_fax_edit.xhtml +++ b/web/admin/fax/admin_fax_edit.xhtml @@ -9,7 +9,7 @@ - + diff --git a/web/admin/landline/admin_landline_edit.xhtml b/web/admin/landline/admin_landline_edit.xhtml index c44d9e2e..6269f8ea 100644 --- a/web/admin/landline/admin_landline_edit.xhtml +++ b/web/admin/landline/admin_landline_edit.xhtml @@ -9,7 +9,7 @@ - + -- 2.39.5