From d859bcd229bf3e7f8b66b39ca6c02f4ed3a1b6f2 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Mon, 12 Oct 2015 13:31:16 +0200 Subject: [PATCH] =?utf8?q?Continued:=20-=20added=20converter=20for=20count?= =?utf8?q?ry=20instance=20-=20added=20converter=20for=20SMS=20provider=20(?= =?utf8?q?cell=20phone)=20-=20enabled=20converts=20in=20template=20-=20upd?= =?utf8?q?ated=20jar(s)=20Signed-off-by:Roland=20H=C3=A4der=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- lib/jcontacts-business-core.jar | Bin 47830 -> 47982 bytes lib/jcontacts-core.jar | Bin 19902 -> 19902 bytes lib/jphone-core.jar | Bin 19469 -> 19613 bytes .../jcountry/data/CountryConverter.java | 138 ++++++++++++++++++ .../smsprovider/SmsProviderConverter.java | 137 +++++++++++++++++ .../templates/generic/form_personal_data.tpl | 8 +- 6 files changed, 279 insertions(+), 4 deletions(-) create mode 100644 src/java/org/mxchange/jcountry/data/CountryConverter.java create mode 100644 src/java/org/mxchange/jphone/phonenumbers/smsprovider/SmsProviderConverter.java diff --git a/lib/jcontacts-business-core.jar b/lib/jcontacts-business-core.jar index a5e07b705621de173e1b4ffe1e88e933a836a1e9..fbe26f77d5b6b551c3c196627875d93f84c8d915 100644 GIT binary patch delta 6867 zcmZ{pX>e3k7RS%)hVFFJOcIs^lQ2M#B@2W&h7h75C|eSiKm#HOosfjZAX^YYz$9u= zQ3Skz!y?Ow4$cTeXf`QSaH?=>#1Wj5nqn;VgHDxImQKx9eweD6|2g+{-D#ye?fd>ezDRA2zekuTh3Iheo=BeWQ1hPBSAA&T9L(2$_GI~O%HR63yp{90-2X1OR|el- z8Mm=#@59a0r~bHk%jlW?iDs$^6|+*0g{d#S6r`Og^m3Sd>Q@!_W`w8@9SqW;Fy!GN zy%wY+K{~1y56z3GO*n5^1J#hCexddCt6Nq!t=>=`|9$0uQ~XhytI|(R93Q3n2xU=r zgo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BQRN7= zdl~Jv;_5@p9=bqrnwZ(p=?YpWUEqFd2f%dqU(O#k=IUM~1fM((q!itdSL}>I2;xfmz=aj5HP3)0kGwz-N~MJm5^W zD9{##+Dvn&e!z2jf#>!CMpzaEccel5EeC_n=Ru2bj)2*(jAFh4+M)q40}dn0rbN5$ z;i+Mp*hl$BnX-}bS?OZDtjQT9%d;kmU9vT6zGzX`pJj!8d(jp4$)nkcGBrCx98~w$ zW`});aleD_$6{H4C{PpX+ zr=^Y8eP}1hsw5+ho1^Yar(yfLvegV&z1%C?d$4`evc)^Qvdzy8`Od)N9c7_cNxg(C zi-K}PK9?I5XDutda4V~)%bkclu)m<}d#P>{H7NTph8nT#nQrKptx>jFelMIH@?C}P zHMR}tSGWn0a;}8M#&gSAymxL1i@}iS}+uP8swP+Vz(P@=#A*O7{F}m-QqhJ9hi! z=1Zm;s!!?cGt?hj<(H9($2t<_*F73`^~TzL4L&0N&+emp>qXY(l6PO(-}PR?5qyW| zf8S7FJE1(e^J;R|#M(_YO-`|E1&=(0>r*>*XF zLpyaj*;D&mZm|17!Z^_S!>swGWbMR~GmWpXHnX2R!1m A<^TWy diff --git a/lib/jcontacts-core.jar b/lib/jcontacts-core.jar index d1599646edb47bc737ba6e93b27c1d992ed0ed88..b977044176df140d0a842f3cd87d2d9913325158 100644 GIT binary patch delta 199 zcmdltn{nT4MxFp~W)?061`Y;>=ER9SnoLcJ6V0bH0ofN6K;$P)AURo<(HKMpF=gt#(G?|_`Pc)y-1Y}=O0Fj?Gf#hUaMq>~a#Apqo z`Wc--)MZ9HAhlVT=`A~mX5#vy3Zj4Lt8s&91?$tCAo{J#4i+FidAX-0(D2ERJRLwh z6)yu273O6Lq9%GdgQ#m>-XKcZI|xLTd;5W?uwctO8&nwMWpv#JEnR_u8$&>b-7AxcY`AHhX7FK& zaZ$IO4{j!IM$I(7OieYK7_%5Zn3ycSWM;-s`b87t2lWq7f6uvvd%G2bHo50Hz2|v5 z=RCjPIrrI%%1f6N=TOpO)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Ku*Z;vQ9QQihJVjKt&8!LcSM8X7jXqn zF_s+{?$2#t@>GjU1x%h%I`2hsUY*@dCtpjrzOX{G6;R=OqbUD>vBnYb8-yYQuvE6x zPzrLWm%^4>DpM@`{A{ULC<}6KiEP=VV4q=&g|SOvO9P!$SfpM{4?6VXR0 zTNrz%*vi;RO3&9ViDo6iTC5{=jklZ4Fk_3&^gM3SvNE<6ZBi>lml)Ps3UxZDOtS3r zQzsZ99Z|<}nmj`tiXZ6g=5oqar;DC+I?cOf-$NGxKEri7(>0_{P(kBT#sh2BX%7~B z_qqRXC&2$kx_Jh~g;0{XR_gTkxnN+clNi>;%{Fejx#=;m-9WE_9g=8{^%wN;SLHwH zwqlfoKdJ0jl}D?}X>k%HO;TG*-k9g}EokZv!xte{7V_m?ZFaZIWqN3IH>_l38E{j! zE2=D)9hRklPqC~jA-$9gJEZ(<2~oBgH;(R_oD9_pWuA*S5J^ZAb|5Njje;fR`3Y(9 zVVHavS;U95h!3h*&JWWKM2KnnFdEedRXthR;scj4GY*Hyhr^5b;HPf_RZ98VS}Knq z6LKsnq$+u(@(40fULllM7eP_=M<@Prq6U#beLf{F6ESH5ieqxXm94!WS{+p?o!6)g zO`vmr;&%Ly^l2X5iSzXEqnb&1bsDU@AH!c)i8+#B)`gjrAd17HOtA7 z<_>_^6W_E9^Fm>3s{XY{oM`sb$65w` zs3oTJwe7veJHvPB)%agc|JmQn^ta-6Ysfe6YDa~RgE#w|nf@zD8oZYlBNBX0G0>LC zP-AVW`o&DS5?7Ee?zJUKGjp|)%&3nIWoTylVOB(#%bq8{Go. + */ +package org.mxchange.jcountry.data; + +import java.text.MessageFormat; +import java.util.List; +import java.util.Objects; +import javax.annotation.PostConstruct; +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; +import javax.faces.convert.Converter; +import javax.faces.convert.FacesConverter; +import javax.inject.Inject; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import org.mxchange.addressbook.beans.country.CountryWebController; +import org.mxchange.jcoreeelogger.beans.local.logger.Log; +import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal; +import org.mxchange.jphone.phonenumbers.smsprovider.CellphoneProvider; + +/** + * Converter for country instance + *

+ * @author Roland Haeder + */ +@FacesConverter (forClass = CellphoneProvider.class, value = "country") +public class CountryConverter implements Converter { + + /** + * Category bean + */ + @Inject + private CountryWebController countryController; + + /** + * Logger instance + */ + @Log + private LoggerBeanLocal loggerBeanLocal; + + /** + * Initialization of this converter + */ + @PostConstruct + public void init () { + // 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 + } catch (final NamingException ex) { + // Continue to throw it + throw new RuntimeException("context.lookup() failed.", ex); //NOI18N + } + } + + @Override + public Object getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { + // Trace message + this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: contect={0},component={1},submittedValue={2} - CALLED!", context, component, submittedValue)); //NOI18N + + // Get full list + List countryList = this.countryController.allCountries(); + + // Is the value null or empty? + if ((null == submittedValue) || (submittedValue.trim().isEmpty())) { + // Return null + return null; + } + + // Init value + Country country = null; + + // Try this better + try { + // Convert it to long + Long countryId = Long.parseLong(submittedValue); + + // Category id should not be below 1 + assert (countryId > 0) : "countryId is smaller than one: " + countryId; //NOI18N + + // Debug message + this.loggerBeanLocal.logDebug(MessageFormat.format("getAsObject: countryId={0}", countryId)); //NOI18N + + // Try to find it + for (final Country cntry : countryList) { + // Is the id the same? (null-safe) + if (Objects.equals(cntry.getCountryId(), countryId)) { + // Found it + country = cntry; + break; + } + } + } catch (final NumberFormatException ex) { + // Log exception (maybe to much?) + this.loggerBeanLocal.logException(ex); + } + + // Trace message + this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: country={0} - EXIT!", country)); //NOI18N + + // Return it + return country; + } + + @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 Country)) { + // Not same interface + throw new IllegalArgumentException(MessageFormat.format("value {0} does not implement Country.", value)); //NOI18N + } + + // Return category id + return String.valueOf(((Country) value).getCountryId()); + } + +} diff --git a/src/java/org/mxchange/jphone/phonenumbers/smsprovider/SmsProviderConverter.java b/src/java/org/mxchange/jphone/phonenumbers/smsprovider/SmsProviderConverter.java new file mode 100644 index 00000000..10fc783a --- /dev/null +++ b/src/java/org/mxchange/jphone/phonenumbers/smsprovider/SmsProviderConverter.java @@ -0,0 +1,137 @@ +/* + * Copyright (C) 2015 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.jphone.phonenumbers.smsprovider; + +import java.text.MessageFormat; +import java.util.List; +import java.util.Objects; +import javax.annotation.PostConstruct; +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; +import javax.faces.convert.Converter; +import javax.faces.convert.FacesConverter; +import javax.inject.Inject; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import org.mxchange.addressbook.beans.smsprovider.SmsProviderWebController; +import org.mxchange.jcoreeelogger.beans.local.logger.Log; +import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal; + +/** + * Converter for SMS provider instance + *

+ * @author Roland Haeder + */ +@FacesConverter (forClass = CellphoneProvider.class, value = "cellphoneCarrier") +public class SmsProviderConverter implements Converter { + + /** + * Category bean + */ + @Inject + private SmsProviderWebController providerController; + + /** + * Logger instance + */ + @Log + private LoggerBeanLocal loggerBeanLocal; + + /** + * Initialization of this converter + */ + @PostConstruct + public void init () { + // 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 + } catch (final NamingException ex) { + // Continue to throw it + throw new RuntimeException("context.lookup() failed.", ex); //NOI18N + } + } + + @Override + public Object getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { + // Trace message + this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: contect={0},component={1},submittedValue={2} - CALLED!", context, component, submittedValue)); //NOI18N + + // Get full list + List providerList = this.providerController.allSmsProvider(); + + // Is the value null or empty? + if ((null == submittedValue) || (submittedValue.trim().isEmpty())) { + // Return null + return null; + } + + // Init value + SmsProvider provider = null; + + // Try this better + try { + // Convert it to long + Long providerId = Long.parseLong(submittedValue); + + // Category id should not be below 1 + assert (providerId > 0) : "providerId is smaller than one: " + providerId; //NOI18N + + // Debug message + this.loggerBeanLocal.logDebug(MessageFormat.format("getAsObject: providerId={0}", providerId)); //NOI18N + + // Try to find it + for (final SmsProvider prov : providerList) { + // Is the id the same? (null-safe) + if (Objects.equals(prov.getProviderId(), providerId)) { + // Found it + provider = prov; + break; + } + } + } catch (final NumberFormatException ex) { + // Log exception (maybe to much?) + this.loggerBeanLocal.logException(ex); + } + + // Trace message + this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: provider={0} - EXIT!", provider)); //NOI18N + + // Return it + return provider; + } + + @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 SmsProvider)) { + // Not same interface + throw new IllegalArgumentException(MessageFormat.format("value {0} does not implement SmsProvider.", value)); //NOI18N + } + + // Return category id + return String.valueOf(((SmsProvider) value).getProviderId()); + } + +} diff --git a/web/WEB-INF/templates/generic/form_personal_data.tpl b/web/WEB-INF/templates/generic/form_personal_data.tpl index c0314bbb..c54746b3 100644 --- a/web/WEB-INF/templates/generic/form_personal_data.tpl +++ b/web/WEB-INF/templates/generic/form_personal_data.tpl @@ -113,7 +113,7 @@

- + @@ -128,7 +128,7 @@
- + @@ -151,7 +151,7 @@
- + @@ -174,7 +174,7 @@
- + -- 2.39.5