From: Roland Häder Date: Wed, 17 Aug 2016 14:45:07 +0000 (+0200) Subject: Please cherry-pick: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=ba6c905c02a09b0b1e608a48ccb46011fadeae05;p=jjobs-war.git Please cherry-pick: - fixed wrong MobileConverter usage on fax/land-line converter - renamed (Fax|LandLine|Mobile)Converter with "Number" in it Signed-off-by: Roland Häder --- diff --git a/src/java/de/chotime/landingpage/converter/fax/LandingFaxConverter.java b/src/java/de/chotime/landingpage/converter/fax/LandingFaxConverter.java deleted file mode 100644 index 28a6c52e..00000000 --- a/src/java/de/chotime/landingpage/converter/fax/LandingFaxConverter.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (C) 2016 Cho-Time GmbH - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package de.chotime.landingpage.converter.fax; - -import java.text.MessageFormat; -import javax.faces.component.UIComponent; -import javax.faces.context.FacesContext; -import javax.faces.convert.Converter; -import javax.faces.convert.ConverterException; -import javax.faces.convert.FacesConverter; -import javax.naming.Context; -import javax.naming.InitialContext; -import javax.naming.NamingException; -import org.mxchange.jcoreeelogger.beans.local.logger.Log; -import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal; -import org.mxchange.jphone.exceptions.PhoneEntityNotFoundException; -import org.mxchange.jphone.phonenumbers.DialableNumber; -import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber; -import org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote; - -/** - * Converter for fax id <-> valid fax number instance - *

- * @author Roland Haeder - */ -@FacesConverter (value = "FaxConverter") -public class LandingFaxConverter implements Converter { - - /** - * Logger instance - */ - @Log - private LoggerBeanLocal loggerBeanLocal; - - /** - * Phone EJB - */ - private PhoneSessionBeanRemote phoneBean; - - /** - * Initialization of this converter - */ - public LandingFaxConverter () { - // Try to get it - try { - // Get initial context - Context context = new InitialContext(); - - // Lookup logger - this.loggerBeanLocal = (LoggerBeanLocal) context.lookup("java:global/jcore-logger-ejb/logger!org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal"); //NOI18N - - // ... and user controller - this.phoneBean = (PhoneSessionBeanRemote) context.lookup("java:global/jlandingpage-ejb/phone!org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote"); //NOI18N - } catch (final NamingException ex) { - // Continue to throw it - throw new RuntimeException(MessageFormat.format("context.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N - } - } - - @Override - public Object getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { - // Is the value null or empty? - if ((null == submittedValue) || (submittedValue.trim().isEmpty())) { - // Warning message - this.loggerBeanLocal.logWarning(MessageFormat.format("{0}.getAsObject(): submittedValue is null or empty - EXIT!", this.getClass().getSimpleName())); //NOI18N - - // Return null - return null; - } - - // Init instance - DialableFaxNumber faxNumber = null; - - try { - // Try to parse the value as long - Long faxNumberId = Long.valueOf(submittedValue); - - // Try to get mobile instance from it - faxNumber = this.phoneBean.findFaxNumberById(faxNumberId); - } catch (final NumberFormatException ex) { - // Throw again - throw new ConverterException(ex); - } catch (final PhoneEntityNotFoundException ex) { - // Debug message - this.loggerBeanLocal.logDebug(MessageFormat.format("{0}.getAsObject(): Exception: {1} - Returning null ...", this.getClass().getSimpleName(), ex)); //NOI18N - } - - // Return it - return faxNumber; - } - - @Override - public String getAsString (final FacesContext context, final UIComponent component, final Object value) { - // Is the object null? - if ((null == value) || ((String.valueOf(value)).isEmpty())) { - // Is null - return ""; //NOI18N - } else if (!(value instanceof DialableNumber)) { - // Not same interface - throw new IllegalArgumentException(MessageFormat.format("value {0} does not implement DialableNumber.", value)); //NOI18N - } - - // Return category id - return String.valueOf(((DialableNumber) value).getPhoneId()); - } - -} diff --git a/src/java/de/chotime/landingpage/converter/fax/LandingFaxNumberConverter.java b/src/java/de/chotime/landingpage/converter/fax/LandingFaxNumberConverter.java new file mode 100644 index 00000000..f133ea0a --- /dev/null +++ b/src/java/de/chotime/landingpage/converter/fax/LandingFaxNumberConverter.java @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2016 Cho-Time GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package de.chotime.landingpage.converter.fax; + +import java.text.MessageFormat; +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; +import javax.faces.convert.Converter; +import javax.faces.convert.ConverterException; +import javax.faces.convert.FacesConverter; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import org.mxchange.jcoreeelogger.beans.local.logger.Log; +import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal; +import org.mxchange.jphone.exceptions.PhoneEntityNotFoundException; +import org.mxchange.jphone.phonenumbers.DialableNumber; +import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber; +import org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote; + +/** + * Converter for fax id <-> valid fax number instance + *

+ * @author Roland Haeder + */ +@FacesConverter (value = "FaxNumberConverter") +public class LandingFaxNumberConverter implements Converter { + + /** + * Logger instance + */ + @Log + private LoggerBeanLocal loggerBeanLocal; + + /** + * Phone EJB + */ + private PhoneSessionBeanRemote phoneBean; + + /** + * Initialization of this converter + */ + public LandingFaxNumberConverter () { + // Try to get it + try { + // Get initial context + Context context = new InitialContext(); + + // Lookup logger + this.loggerBeanLocal = (LoggerBeanLocal) context.lookup("java:global/jcore-logger-ejb/logger!org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal"); //NOI18N + + // ... and user controller + this.phoneBean = (PhoneSessionBeanRemote) context.lookup("java:global/jlandingpage-ejb/phone!org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote"); //NOI18N + } catch (final NamingException ex) { + // Continue to throw it + throw new RuntimeException(MessageFormat.format("context.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N + } + } + + @Override + public Object getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { + // Is the value null or empty? + if ((null == submittedValue) || (submittedValue.trim().isEmpty())) { + // Warning message + this.loggerBeanLocal.logWarning(MessageFormat.format("{0}.getAsObject(): submittedValue is null or empty - EXIT!", this.getClass().getSimpleName())); //NOI18N + + // Return null + return null; + } + + // Init instance + DialableFaxNumber faxNumber = null; + + try { + // Try to parse the value as long + Long faxNumberId = Long.valueOf(submittedValue); + + // Try to get mobile instance from it + faxNumber = this.phoneBean.findFaxNumberById(faxNumberId); + } catch (final NumberFormatException ex) { + // Throw again + throw new ConverterException(ex); + } catch (final PhoneEntityNotFoundException ex) { + // Debug message + this.loggerBeanLocal.logDebug(MessageFormat.format("{0}.getAsObject(): Exception: {1} - Returning null ...", this.getClass().getSimpleName(), ex)); //NOI18N + } + + // Return it + return faxNumber; + } + + @Override + public String getAsString (final FacesContext context, final UIComponent component, final Object value) { + // Is the object null? + if ((null == value) || ((String.valueOf(value)).isEmpty())) { + // Is null + return ""; //NOI18N + } else if (!(value instanceof DialableNumber)) { + // Not same interface + throw new IllegalArgumentException(MessageFormat.format("value {0} does not implement DialableNumber.", value)); //NOI18N + } + + // Return category id + return String.valueOf(((DialableNumber) value).getPhoneId()); + } + +} diff --git a/src/java/de/chotime/landingpage/converter/landline/LandingLandLineConverter.java b/src/java/de/chotime/landingpage/converter/landline/LandingLandLineConverter.java deleted file mode 100644 index fdf2758d..00000000 --- a/src/java/de/chotime/landingpage/converter/landline/LandingLandLineConverter.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (C) 2016 Cho-Time GmbH - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package de.chotime.landingpage.converter.landline; - -import java.text.MessageFormat; -import javax.faces.component.UIComponent; -import javax.faces.context.FacesContext; -import javax.faces.convert.Converter; -import javax.faces.convert.ConverterException; -import javax.faces.convert.FacesConverter; -import javax.naming.Context; -import javax.naming.InitialContext; -import javax.naming.NamingException; -import org.mxchange.jcoreeelogger.beans.local.logger.Log; -import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal; -import org.mxchange.jphone.exceptions.PhoneEntityNotFoundException; -import org.mxchange.jphone.phonenumbers.DialableNumber; -import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber; -import org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote; - -/** - * Converter for land-line id <-> valid land-line number instance - *

- * @author Roland Haeder - */ -@FacesConverter (value = "LandLineConverter") -public class LandingLandLineConverter implements Converter { - - /** - * Logger instance - */ - @Log - private LoggerBeanLocal loggerBeanLocal; - - /** - * Phone EJB - */ - private PhoneSessionBeanRemote phoneBean; - - /** - * Initialization of this converter - */ - public LandingLandLineConverter () { - // Try to get it - try { - // Get initial context - Context context = new InitialContext(); - - // Lookup logger - this.loggerBeanLocal = (LoggerBeanLocal) context.lookup("java:global/jcore-logger-ejb/logger!org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal"); //NOI18N - - // ... and user controller - this.phoneBean = (PhoneSessionBeanRemote) context.lookup("java:global/jlandingpage-ejb/phone!org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote"); //NOI18N - } catch (final NamingException ex) { - // Continue to throw it - throw new RuntimeException(MessageFormat.format("context.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N - } - } - - @Override - public Object getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { - // Is the value null or empty? - if ((null == submittedValue) || (submittedValue.trim().isEmpty())) { - // Warning message - this.loggerBeanLocal.logWarning(MessageFormat.format("{0}.getAsObject(): submittedValue is null or empty - EXIT!", this.getClass().getSimpleName())); //NOI18N - - // Return null - return null; - } - - // Init instance - DialableLandLineNumber landLineNumber = null; - - try { - // Try to parse the value as long - Long landLineNumberId = Long.valueOf(submittedValue); - - // Try to get mobile instance from it - landLineNumber = this.phoneBean.findLandLineNumberById(landLineNumberId); - } catch (final NumberFormatException ex) { - // Throw again - throw new ConverterException(ex); - } catch (final PhoneEntityNotFoundException ex) { - // Debug message - this.loggerBeanLocal.logDebug(MessageFormat.format("{0}.getAsObject(): Exception: {1} - Returning null ...", this.getClass().getSimpleName(), ex)); //NOI18N - } - - // Return it - return landLineNumber; - } - - @Override - public String getAsString (final FacesContext context, final UIComponent component, final Object value) { - // Is the object null? - if ((null == value) || ((String.valueOf(value)).isEmpty())) { - // Is null - return ""; //NOI18N - } else if (!(value instanceof DialableNumber)) { - // Not same interface - throw new IllegalArgumentException(MessageFormat.format("value {0} does not implement DialableNumber.", value)); //NOI18N - } - - // Return category id - return String.valueOf(((DialableNumber) value).getPhoneId()); - } - -} diff --git a/src/java/de/chotime/landingpage/converter/landline/LandingLandLineNumberConverter.java b/src/java/de/chotime/landingpage/converter/landline/LandingLandLineNumberConverter.java new file mode 100644 index 00000000..2630663b --- /dev/null +++ b/src/java/de/chotime/landingpage/converter/landline/LandingLandLineNumberConverter.java @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2016 Cho-Time GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package de.chotime.landingpage.converter.landline; + +import java.text.MessageFormat; +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; +import javax.faces.convert.Converter; +import javax.faces.convert.ConverterException; +import javax.faces.convert.FacesConverter; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import org.mxchange.jcoreeelogger.beans.local.logger.Log; +import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal; +import org.mxchange.jphone.exceptions.PhoneEntityNotFoundException; +import org.mxchange.jphone.phonenumbers.DialableNumber; +import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber; +import org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote; + +/** + * Converter for land-line id <-> valid land-line number instance + *

+ * @author Roland Haeder + */ +@FacesConverter (value = "LandLineNumberConverter") +public class LandingLandLineNumberConverter implements Converter { + + /** + * Logger instance + */ + @Log + private LoggerBeanLocal loggerBeanLocal; + + /** + * Phone EJB + */ + private PhoneSessionBeanRemote phoneBean; + + /** + * Initialization of this converter + */ + public LandingLandLineNumberConverter () { + // Try to get it + try { + // Get initial context + Context context = new InitialContext(); + + // Lookup logger + this.loggerBeanLocal = (LoggerBeanLocal) context.lookup("java:global/jcore-logger-ejb/logger!org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal"); //NOI18N + + // ... and user controller + this.phoneBean = (PhoneSessionBeanRemote) context.lookup("java:global/jlandingpage-ejb/phone!org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote"); //NOI18N + } catch (final NamingException ex) { + // Continue to throw it + throw new RuntimeException(MessageFormat.format("context.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N + } + } + + @Override + public Object getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { + // Is the value null or empty? + if ((null == submittedValue) || (submittedValue.trim().isEmpty())) { + // Warning message + this.loggerBeanLocal.logWarning(MessageFormat.format("{0}.getAsObject(): submittedValue is null or empty - EXIT!", this.getClass().getSimpleName())); //NOI18N + + // Return null + return null; + } + + // Init instance + DialableLandLineNumber landLineNumber = null; + + try { + // Try to parse the value as long + Long landLineNumberId = Long.valueOf(submittedValue); + + // Try to get mobile instance from it + landLineNumber = this.phoneBean.findLandLineNumberById(landLineNumberId); + } catch (final NumberFormatException ex) { + // Throw again + throw new ConverterException(ex); + } catch (final PhoneEntityNotFoundException ex) { + // Debug message + this.loggerBeanLocal.logDebug(MessageFormat.format("{0}.getAsObject(): Exception: {1} - Returning null ...", this.getClass().getSimpleName(), ex)); //NOI18N + } + + // Return it + return landLineNumber; + } + + @Override + public String getAsString (final FacesContext context, final UIComponent component, final Object value) { + // Is the object null? + if ((null == value) || ((String.valueOf(value)).isEmpty())) { + // Is null + return ""; //NOI18N + } else if (!(value instanceof DialableNumber)) { + // Not same interface + throw new IllegalArgumentException(MessageFormat.format("value {0} does not implement DialableNumber.", value)); //NOI18N + } + + // Return category id + return String.valueOf(((DialableNumber) value).getPhoneId()); + } + +} diff --git a/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionBean.java b/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionBean.java index f0e11841..0fe1152a 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionBean.java +++ b/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionBean.java @@ -175,7 +175,7 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job private boolean isMobileUnlinked; /** - * Cellphone number + * Mobile number */ private Long mobileNumber; diff --git a/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionController.java b/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionController.java index 889e5407..bdc31008 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionController.java +++ b/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionController.java @@ -172,14 +172,14 @@ public interface JobsContactWebSessionController extends Serializable { /** * Getter for mobile number *

- * @return Cellphone number + * @return Mobile number */ Long getMobileNumber (); /** * Setter for mobile number *

- * @param mobileNumber Cellphone number + * @param mobileNumber Mobile number */ void setMobileNumber (final Long mobileNumber); diff --git a/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelper.java b/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelper.java index 5f70dd18..85acc7ed 100644 --- a/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelper.java +++ b/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelper.java @@ -71,7 +71,7 @@ public class JobsWebRequestHelper implements JobsWebRequestController { private DialableLandLineNumber landLineNumber; /** - * Cell phone number + * Mobile number */ private DialableMobileNumber mobileNumber; diff --git a/src/java/org/mxchange/jjobs/beans/phone/JobsPhoneWebApplicationBean.java b/src/java/org/mxchange/jjobs/beans/phone/JobsPhoneWebApplicationBean.java index 56b137ed..d473e4dc 100644 --- a/src/java/org/mxchange/jjobs/beans/phone/JobsPhoneWebApplicationBean.java +++ b/src/java/org/mxchange/jjobs/beans/phone/JobsPhoneWebApplicationBean.java @@ -206,9 +206,9 @@ public class JobsPhoneWebApplicationBean extends BaseJobsController implements J * Uniquely add given mobile number to this bean's list. First remove the * old instance (by id number), then re-add it again. *

- * @param mobileNumber Cellphone number to add + * @param mobileNumber Mobile number to add */ - private void uniqueAddCellphoneNumber (final DialableMobileNumber mobileNumber) { + private void uniqueAddMobileNumber (final DialableMobileNumber mobileNumber) { // Make sure the parameter is valid if (null == mobileNumber) { // Throw NPE @@ -330,7 +330,7 @@ public class JobsPhoneWebApplicationBean extends BaseJobsController implements J // Is mobile set? if (contact.getContactMobileNumber() instanceof DialableMobileNumber) { // Unique-add it - this.uniqueAddCellphoneNumber(contact.getContactMobileNumber()); + this.uniqueAddMobileNumber(contact.getContactMobileNumber()); } // Is land-line set? diff --git a/src/java/org/mxchange/jjobs/converter/cellphone/JobsMobileConverter.java b/src/java/org/mxchange/jjobs/converter/cellphone/JobsMobileConverter.java deleted file mode 100644 index 74bd6a2e..00000000 --- a/src/java/org/mxchange/jjobs/converter/cellphone/JobsMobileConverter.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (C) 2016 Roland Haeder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package org.mxchange.jjobs.converter.cellphone; - -import java.text.MessageFormat; -import javax.faces.component.UIComponent; -import javax.faces.context.FacesContext; -import javax.faces.convert.Converter; -import javax.faces.convert.ConverterException; -import javax.faces.convert.FacesConverter; -import javax.naming.Context; -import javax.naming.InitialContext; -import javax.naming.NamingException; -import org.mxchange.jcoreeelogger.beans.local.logger.Log; -import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal; -import org.mxchange.jphone.exceptions.PhoneEntityNotFoundException; -import org.mxchange.jphone.phonenumbers.DialableNumber; -import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber; -import org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote; - -/** - * Converter for mobile id <-> valid mobile instance - *

- * @author Roland Haeder - */ -@FacesConverter (value = "CellphoneConverter") -public class JobsMobileConverter implements Converter { - - /** - * Logger instance - */ - @Log - private LoggerBeanLocal loggerBeanLocal; - - /** - * Phone EJB - */ - private PhoneSessionBeanRemote phoneBean; - - /** - * Initialization of this converter - */ - public JobsMobileConverter () { - // Try to get it - try { - // Get initial context - Context context = new InitialContext(); - - // Lookup logger - this.loggerBeanLocal = (LoggerBeanLocal) context.lookup("java:global/jcore-logger-ejb/logger!org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal"); //NOI18N - - // ... and user controller - this.phoneBean = (PhoneSessionBeanRemote) context.lookup("java:global/jjobs-ejb/phone!org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote"); //NOI18N - } catch (final NamingException ex) { - // Continue to throw it - throw new RuntimeException(MessageFormat.format("context.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N - } - } - - @Override - public Object getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { - // Trace message - // NOISY-DEBUG: this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: context={0},component={1},submittedValue={2} - CALLED!", context, component, submittedValue)); //NOI18N - - // Is the value null or empty? - if ((null == submittedValue) || (submittedValue.trim().isEmpty())) { - // Warning message - this.loggerBeanLocal.logWarning(MessageFormat.format("{0}.getAsObject(): submittedValue is null or empty - EXIT!", this.getClass().getSimpleName())); //NOI18N - - // Return null - return null; - } - - // Init instance - DialableMobileNumber mobileNumber = null; - - try { - // Try to parse the value as long - Long mobileNumberId = Long.valueOf(submittedValue); - - // Try to get mobile instance from it - mobileNumber = this.phoneBean.findMobileNumberById(mobileNumberId); - } catch (final NumberFormatException ex) { - // Throw again - throw new ConverterException(ex); - } catch (final PhoneEntityNotFoundException ex) { - // Debug message - this.loggerBeanLocal.logDebug(MessageFormat.format("{0}.getAsObject(): Exception: {1} - Returning null ...", this.getClass().getSimpleName(), ex)); //NOI18N - } - - // Trace message - // NOISY-DEBUG: this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: cellphone={0} - EXIT!", cellphone)); //NOI18N - - // Return it - return mobileNumber; - } - - @Override - public String getAsString (final FacesContext context, final UIComponent component, final Object value) { - // Is the object null? - if ((null == value) || ((String.valueOf(value)).isEmpty())) { - // Is null - return ""; //NOI18N - } else if (!(value instanceof DialableNumber)) { - // Not same interface - throw new IllegalArgumentException(MessageFormat.format("value {0} does not implement DialableNumber.", value)); //NOI18N - } - - // Return category id - return String.valueOf(((DialableNumber) value).getPhoneId()); - } - -} diff --git a/src/java/org/mxchange/jjobs/converter/mobile/JobsMobileConverter.java b/src/java/org/mxchange/jjobs/converter/mobile/JobsMobileConverter.java new file mode 100644 index 00000000..56869c78 --- /dev/null +++ b/src/java/org/mxchange/jjobs/converter/mobile/JobsMobileConverter.java @@ -0,0 +1,127 @@ +/* + * Copyright (C) 2016 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.mxchange.jjobs.converter.mobile; + +import java.text.MessageFormat; +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; +import javax.faces.convert.Converter; +import javax.faces.convert.ConverterException; +import javax.faces.convert.FacesConverter; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import org.mxchange.jcoreeelogger.beans.local.logger.Log; +import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal; +import org.mxchange.jphone.exceptions.PhoneEntityNotFoundException; +import org.mxchange.jphone.phonenumbers.DialableNumber; +import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber; +import org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote; + +/** + * Converter for mobile id <-> valid mobile instance + *

+ * @author Roland Haeder + */ +@FacesConverter (value = "CellphoneConverter") +public class JobsMobileConverter implements Converter { + + /** + * Logger instance + */ + @Log + private LoggerBeanLocal loggerBeanLocal; + + /** + * Phone EJB + */ + private PhoneSessionBeanRemote phoneBean; + + /** + * Initialization of this converter + */ + public JobsMobileConverter () { + // Try to get it + try { + // Get initial context + Context context = new InitialContext(); + + // Lookup logger + this.loggerBeanLocal = (LoggerBeanLocal) context.lookup("java:global/jcore-logger-ejb/logger!org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal"); //NOI18N + + // ... and user controller + this.phoneBean = (PhoneSessionBeanRemote) context.lookup("java:global/jjobs-ejb/phone!org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote"); //NOI18N + } catch (final NamingException ex) { + // Continue to throw it + throw new RuntimeException(MessageFormat.format("context.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N + } + } + + @Override + public Object getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { + // Trace message + // NOISY-DEBUG: this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: context={0},component={1},submittedValue={2} - CALLED!", context, component, submittedValue)); //NOI18N + + // Is the value null or empty? + if ((null == submittedValue) || (submittedValue.trim().isEmpty())) { + // Warning message + this.loggerBeanLocal.logWarning(MessageFormat.format("{0}.getAsObject(): submittedValue is null or empty - EXIT!", this.getClass().getSimpleName())); //NOI18N + + // Return null + return null; + } + + // Init instance + DialableMobileNumber mobileNumber = null; + + try { + // Try to parse the value as long + Long mobileNumberId = Long.valueOf(submittedValue); + + // Try to get mobile instance from it + mobileNumber = this.phoneBean.findMobileNumberById(mobileNumberId); + } catch (final NumberFormatException ex) { + // Throw again + throw new ConverterException(ex); + } catch (final PhoneEntityNotFoundException ex) { + // Debug message + this.loggerBeanLocal.logDebug(MessageFormat.format("{0}.getAsObject(): Exception: {1} - Returning null ...", this.getClass().getSimpleName(), ex)); //NOI18N + } + + // Trace message + // NOISY-DEBUG: this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: cellphone={0} - EXIT!", cellphone)); //NOI18N + + // Return it + return mobileNumber; + } + + @Override + public String getAsString (final FacesContext context, final UIComponent component, final Object value) { + // Is the object null? + if ((null == value) || ((String.valueOf(value)).isEmpty())) { + // Is null + return ""; //NOI18N + } else if (!(value instanceof DialableNumber)) { + // Not same interface + throw new IllegalArgumentException(MessageFormat.format("value {0} does not implement DialableNumber.", value)); //NOI18N + } + + // Return category id + return String.valueOf(((DialableNumber) value).getPhoneId()); + } + +} diff --git a/src/java/org/mxchange/localization/bundle_de_DE.properties b/src/java/org/mxchange/localization/bundle_de_DE.properties index 37d91d33..89cce75e 100644 --- a/src/java/org/mxchange/localization/bundle_de_DE.properties +++ b/src/java/org/mxchange/localization/bundle_de_DE.properties @@ -597,7 +597,7 @@ PAGE_TITLE_ADMIN_LOCK_USER=Benutzeraccount sperren CONTENT_TITLE_ADMIN_LOCK_USER=Benutzeraccount sperren: ERROR_BEAN_HELPER_USER_NOT_SET=Fehler: Instanz 'user' im Bean-Helper nicht gesetzt. ERROR_BEAN_HELPER_CONTACT_NOT_SET=Fehler: Instanz 'contact' im Bean-Helper nicht gesetzt. -ERROR_BEAN_HELPER_MOBILE_NUMBER_NOT_SET=Fehler: Instanz 'cellPhone' in Bean-Helper nicht gesetzt. +ERROR_BEAN_HELPER_MOBILE_NUMBER_NOT_SET=Fehler: Instanz 'mobile' in Bean-Helper nicht gesetzt. CONTENT_TITLE_ADMIN_LIST_CONTACT_MOBILE=Mobiltelefonnummern auflisten: ADMIN_LIST_MOBILE_EMPTY=Es sind keine Mobilfunknummern gespeichert. ADMIN_MENU_PHONE_NUMBERS_TITLE=Telefonnummern: diff --git a/src/java/org/mxchange/localization/bundle_en_US.properties b/src/java/org/mxchange/localization/bundle_en_US.properties index 0586d99f..f9e28eea 100644 --- a/src/java/org/mxchange/localization/bundle_en_US.properties +++ b/src/java/org/mxchange/localization/bundle_en_US.properties @@ -506,7 +506,7 @@ ADMIN_MENU_CONTACT_TITLE=Manage contact data LINK_ADMIN_LIST_CONTACT=List contact data LINK_ADMIN_LIST_CONTACT_TITLE=Lists all contact data regardless where they was created. ADMIN_CONTACT_COUNTRY_CODE=Country code: -ADMIN_CONTACT_MOBILE_NUMBER=Cellphone number: +ADMIN_CONTACT_MOBILE_NUMBER=Mobile number: ADMIN_CONTACT_LANDLINE_NUMBER=Phone number: ADMIN_CONTACT_FAX_NUMBER=Fax number: PAGE_TITLE_ADMIN_EXPORT_CONTACT=Export contact data @@ -532,7 +532,7 @@ ADMIN_EXPORT_CONTACT_ZIP_CODE=ZIP code ADMIN_EXPORT_CONTACT_CITY=City ADMIN_EXPORT_CONTACT_EMAIL_ADDRESS=Email address ADMIN_EXPORT_CONTACT_BIRTHDAY=Birthday -ADMIN_EXPORT_CONTACT_MOBILE_NUMBER=Cellphone number +ADMIN_EXPORT_CONTACT_MOBILE_NUMBER=Mobile number ADMIN_EXPORT_CONTACT_LANDLINE_NUMBER=Land-line number ADMIN_EXPORT_CONTACT_FAX_NUMBER=Fax number ADMIN_EXPORT_CONTACT_CREATED=Entry created @@ -597,11 +597,11 @@ PAGE_TITLE_ADMIN_LOCK_USER=Lock user account CONTENT_TITLE_ADMIN_LOCK_USER=Lock user account: ERROR_BEAN_HELPER_USER_NOT_SET=Error: Instance 'user' not set in bean helper. ERROR_BEAN_HELPER_CONTACT_NOT_SET=Error: Instance 'contact' not set in bean helper. -ERROR_BEAN_HELPER_MOBILE_NUMBER_NOT_SET=Error: Instance 'cellPhone' in bean helper not set. +ERROR_BEAN_HELPER_MOBILE_NUMBER_NOT_SET=Error: Instance 'mobile' in bean helper not set. CONTENT_TITLE_ADMIN_LIST_CONTACT_MOBILE=List mobile phone numbers: ADMIN_LIST_MOBILE_EMPTY=No mobile numbers are saved. ADMIN_MENU_PHONE_NUMBERS_TITLE=Phone numbers: -LINK_ADMIN_LIST_MOBILE_PHONE_NUMBERS=Cell phone numbers ... +LINK_ADMIN_LIST_MOBILE_PHONE_NUMBERS=Mobile numbers ... LINK_ADMIN_LIST_MOBILE_PHONE_NUMBERS_TITLE=List all mobile numbers. ADMIN_SHOW_PHONE_CREATED=Created: ADMIN_SHOW_PHONE_UPDATED=Last changed: @@ -640,7 +640,7 @@ ERROR_USER_PASSWORD_MISMATCH=You have entered a wrong password. ERROR_USER_NAME_ALREADY_USED=User name already used. Please enter another name. ERROR_EMAIL_ADDRESSES_MISMATCHING=Both entered email addresses are not the same. ERROR_EMAIL_ADDRESS_ALREADY_USED=Your entered email address is already used. Please enter another and try again. -ERROR_MOBILE_NUMBER_CONTACT_NOT_LINKED=Error: Cell phone id {0} is not linked with contact id {1}. +ERROR_MOBILE_NUMBER_CONTACT_NOT_LINKED=Error: Mobile id {0} is not linked with contact id {1}. ADMIN_ADD_CONTACT_MOBILE_NUMBER_FORM_TITLE=Add mobile number to this contact ADMIN_SELECT_MOBILE_NUMBER=Choose mobile number: BUTTON_ADMIN_LINK_ADD_CONTACT_MOBILE_NUMBER=Add mobile number to contact diff --git a/web/WEB-INF/templates/admin/fax/admin_form_add_contact_fax.tpl b/web/WEB-INF/templates/admin/fax/admin_form_add_contact_fax.tpl index 8b1cd7a4..51a19182 100644 --- a/web/WEB-INF/templates/admin/fax/admin_form_add_contact_fax.tpl +++ b/web/WEB-INF/templates/admin/fax/admin_form_add_contact_fax.tpl @@ -24,7 +24,7 @@

- + @@ -49,7 +49,7 @@ diff --git a/web/WEB-INF/templates/admin/landline/admin_form_add_contact_landline.tpl b/web/WEB-INF/templates/admin/landline/admin_form_add_contact_landline.tpl index ed187a1a..db3e6c81 100644 --- a/web/WEB-INF/templates/admin/landline/admin_form_add_contact_landline.tpl +++ b/web/WEB-INF/templates/admin/landline/admin_form_add_contact_landline.tpl @@ -24,7 +24,7 @@
- + @@ -49,7 +49,7 @@ diff --git a/web/WEB-INF/templates/admin/mobile/admin_form_add_contact_mobile.tpl b/web/WEB-INF/templates/admin/mobile/admin_form_add_contact_mobile.tpl index bb26071e..cf8286e4 100644 --- a/web/WEB-INF/templates/admin/mobile/admin_form_add_contact_mobile.tpl +++ b/web/WEB-INF/templates/admin/mobile/admin_form_add_contact_mobile.tpl @@ -19,12 +19,12 @@
- +
- - + + @@ -49,7 +49,7 @@ diff --git a/web/admin/contact/admin_contact_export.xhtml b/web/admin/contact/admin_contact_export.xhtml index f4daf63c..687aac11 100644 --- a/web/admin/contact/admin_contact_export.xhtml +++ b/web/admin/contact/admin_contact_export.xhtml @@ -123,7 +123,7 @@ - + diff --git a/web/admin/contact/unlink/admin_contact_fax_unlink.xhtml b/web/admin/contact/unlink/admin_contact_fax_unlink.xhtml index 010c67a1..68ae1074 100644 --- a/web/admin/contact/unlink/admin_contact_fax_unlink.xhtml +++ b/web/admin/contact/unlink/admin_contact_fax_unlink.xhtml @@ -8,7 +8,7 @@ > - + diff --git a/web/admin/contact/unlink/admin_contact_landline_unlink.xhtml b/web/admin/contact/unlink/admin_contact_landline_unlink.xhtml index 7a4ca02c..cb177c4d 100644 --- a/web/admin/contact/unlink/admin_contact_landline_unlink.xhtml +++ b/web/admin/contact/unlink/admin_contact_landline_unlink.xhtml @@ -8,7 +8,7 @@ > - + diff --git a/web/admin/contact/unlink/admin_contact_mobile_unlink.xhtml b/web/admin/contact/unlink/admin_contact_mobile_unlink.xhtml index 717388eb..80116b69 100644 --- a/web/admin/contact/unlink/admin_contact_mobile_unlink.xhtml +++ b/web/admin/contact/unlink/admin_contact_mobile_unlink.xhtml @@ -8,7 +8,7 @@ > - + diff --git a/web/admin/fax/admin_fax_delete.xhtml b/web/admin/fax/admin_fax_delete.xhtml index 9f9ec096..fa603a2f 100644 --- a/web/admin/fax/admin_fax_delete.xhtml +++ b/web/admin/fax/admin_fax_delete.xhtml @@ -8,7 +8,7 @@ > - + diff --git a/web/admin/fax/admin_fax_edit.xhtml b/web/admin/fax/admin_fax_edit.xhtml index cef2bdfd..af133657 100644 --- a/web/admin/fax/admin_fax_edit.xhtml +++ b/web/admin/fax/admin_fax_edit.xhtml @@ -8,7 +8,7 @@ > - + diff --git a/web/admin/fax/admin_fax_show.xhtml b/web/admin/fax/admin_fax_show.xhtml index 347e5350..f610b2db 100644 --- a/web/admin/fax/admin_fax_show.xhtml +++ b/web/admin/fax/admin_fax_show.xhtml @@ -8,7 +8,7 @@ > - + diff --git a/web/admin/landline/admin_landline_delete.xhtml b/web/admin/landline/admin_landline_delete.xhtml index faae7ca8..d9c359fd 100644 --- a/web/admin/landline/admin_landline_delete.xhtml +++ b/web/admin/landline/admin_landline_delete.xhtml @@ -8,7 +8,7 @@ > - + diff --git a/web/admin/landline/admin_landline_edit.xhtml b/web/admin/landline/admin_landline_edit.xhtml index edb64ce5..c44d9e2e 100644 --- a/web/admin/landline/admin_landline_edit.xhtml +++ b/web/admin/landline/admin_landline_edit.xhtml @@ -8,7 +8,7 @@ > - + diff --git a/web/admin/landline/admin_landline_show.xhtml b/web/admin/landline/admin_landline_show.xhtml index dba6795f..773e8aa1 100644 --- a/web/admin/landline/admin_landline_show.xhtml +++ b/web/admin/landline/admin_landline_show.xhtml @@ -8,7 +8,7 @@ > - + diff --git a/web/admin/mobile/admin_mobile_delete.xhtml b/web/admin/mobile/admin_mobile_delete.xhtml index e0192800..f98c0c41 100644 --- a/web/admin/mobile/admin_mobile_delete.xhtml +++ b/web/admin/mobile/admin_mobile_delete.xhtml @@ -8,7 +8,7 @@ > - + diff --git a/web/admin/mobile/admin_mobile_edit.xhtml b/web/admin/mobile/admin_mobile_edit.xhtml index 8b51bc60..33a13144 100644 --- a/web/admin/mobile/admin_mobile_edit.xhtml +++ b/web/admin/mobile/admin_mobile_edit.xhtml @@ -8,7 +8,7 @@ > - + diff --git a/web/admin/mobile/admin_mobile_show.xhtml b/web/admin/mobile/admin_mobile_show.xhtml index c511af26..77639b32 100644 --- a/web/admin/mobile/admin_mobile_show.xhtml +++ b/web/admin/mobile/admin_mobile_show.xhtml @@ -8,7 +8,7 @@ > - + diff --git a/web/admin/user/admin_user_export.xhtml b/web/admin/user/admin_user_export.xhtml index 05b93c00..2039cccb 100644 --- a/web/admin/user/admin_user_export.xhtml +++ b/web/admin/user/admin_user_export.xhtml @@ -141,7 +141,7 @@ - +