From: Roland Haeder Date: Mon, 12 Oct 2015 09:04:06 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=2300c0e560dffeb0f8d5d3e11b6fc84946c694c4;p=jphone-core.git Continued: - added named query for all SMS provider - added validator for phone, fax and mobile numbers - this requires the Java EE 7 API to be added - also jcoreee is required (for abstract BaseLongValidator) class - allow null for all numbers Signed-off-by:Roland Häder --- diff --git a/lib/javaee-api-7.0/javaee-api-7.0.jar b/lib/javaee-api-7.0/javaee-api-7.0.jar new file mode 100644 index 0000000..9e38d4c Binary files /dev/null and b/lib/javaee-api-7.0/javaee-api-7.0.jar differ diff --git a/lib/javaee-api-7.0/javaee-doc-api.jar b/lib/javaee-api-7.0/javaee-doc-api.jar new file mode 100644 index 0000000..2859e3d Binary files /dev/null and b/lib/javaee-api-7.0/javaee-doc-api.jar differ diff --git a/lib/jcoreee.jar b/lib/jcoreee.jar new file mode 100644 index 0000000..3d91b2c Binary files /dev/null and b/lib/jcoreee.jar differ diff --git a/lib/nblibraries.properties b/lib/nblibraries.properties index 7ee5412..2e2f7c6 100644 --- a/lib/nblibraries.properties +++ b/lib/nblibraries.properties @@ -2,6 +2,12 @@ libs.CopyLibs.classpath=\ ${base}/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar libs.CopyLibs.displayName=CopyLibs Task libs.CopyLibs.prop-version=2.0 +libs.javaee-api-7.0.classpath=\ + ${base}/javaee-api-7.0/javaee-api-7.0.jar +libs.javaee-api-7.0.displayName=Java EE 7 API Library +libs.javaee-api-7.0.javadoc=\ + ${base}/javaee-api-7.0/javaee-doc-api.jar +libs.javaee-api-7.0.prop-maven-dependencies=javax:javaee-api:7.0:jar libs.jpa20-persistence.classpath=\ ${base}/jpa20-persistence/javax.persistence_2.1.0.v201304241213.jar libs.jpa20-persistence.displayName=Persistence (JPA 2.1) diff --git a/nbproject/project.properties b/nbproject/project.properties index baf13af..4c91511 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -30,14 +30,17 @@ dist.jar=${dist.dir}/jphone-core.jar dist.javadoc.dir=${dist.dir}/javadoc endorsed.classpath= excludes= +file.reference.jcoreee.jar=lib/jcoreee.jar file.reference.jcountry-core.jar=lib/jcountry-core.jar includes=** jar.archive.disabled=${jnlp.enabled} jar.compress=false jar.index=${jnlp.enabled} javac.classpath=\ + ${file.reference.jcoreee.jar}:\ ${file.reference.jcountry-core.jar}:\ - ${libs.jpa20-persistence.classpath} + ${libs.jpa20-persistence.classpath}:\ + ${libs.javaee-api-7.0.classpath} # Space-separated list of extra javac options javac.compilerargs=-Xlint:unchecked -Xlint:deprecation javac.deprecation=true @@ -89,6 +92,7 @@ run.test.classpath=\ ${javac.test.classpath}:\ ${build.test.classes.dir} source.encoding=UTF-8 +source.reference.jcoreee.jar=../jcoreee/src/ source.reference.jcountry-core.jar=../jcountry-core/src/ src.dir=src test.src.dir=test diff --git a/src/org/mxchange/jphone/phonenumbers/DialableNumber.java b/src/org/mxchange/jphone/phonenumbers/DialableNumber.java index 2c157f6..e663ebd 100644 --- a/src/org/mxchange/jphone/phonenumbers/DialableNumber.java +++ b/src/org/mxchange/jphone/phonenumbers/DialableNumber.java @@ -31,14 +31,14 @@ public interface DialableNumber extends Serializable { *

* @return Country instance */ - public Country getCountry (); + public Country getPhoneCountry (); /** * Setter for country instance ('s dial data) *

* @param country Country instance */ - public void setCountry (final Country country); + public void setPhoneCountry (final Country country); /** * Getter for id number diff --git a/src/org/mxchange/jphone/phonenumbers/cellphone/CellphoneNumber.java b/src/org/mxchange/jphone/phonenumbers/cellphone/CellphoneNumber.java index d06a3bb..a173007 100644 --- a/src/org/mxchange/jphone/phonenumbers/cellphone/CellphoneNumber.java +++ b/src/org/mxchange/jphone/phonenumbers/cellphone/CellphoneNumber.java @@ -27,7 +27,6 @@ import javax.persistence.JoinColumn; import javax.persistence.OneToOne; import javax.persistence.Table; import org.mxchange.jcountry.data.Country; -import org.mxchange.jcountry.data.CountryData; import org.mxchange.jphone.phonenumbers.smsprovider.CellphoneProvider; import org.mxchange.jphone.phonenumbers.smsprovider.SmsProvider; @@ -68,11 +67,33 @@ public class CellphoneNumber implements DialableCellphoneNumber, Comparable + * @param cellphoneCarrier Cellphone carrier instance + * @param cellphoneNumber Cellphone number */ - @JoinColumn (name = "cellphone_country_id", nullable = false) - @OneToOne (targetEntity = CountryData.class, optional = false, cascade = CascadeType.ALL) - private Country country; + public CellphoneNumber (final SmsProvider cellphoneCarrier, final Long cellphoneNumber) { + this.cellphoneProvider = cellphoneCarrier; + this.phoneNumber = cellphoneNumber; + } + + /** + * Protected constructor + */ + protected CellphoneNumber () { + } + + @Override + @Deprecated + public Country getPhoneCountry () { + throw new UnsupportedOperationException("The country code is provided by SmsProvider."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + @Deprecated + public void setPhoneCountry (final Country country) { + throw new UnsupportedOperationException("The country code is provided by SmsProvider."); //To change body of generated methods, choose Tools | Templates. + } @Override public Long getPhoneId () { @@ -105,11 +126,13 @@ public class CellphoneNumber implements DialableCellphoneNumber, Comparable + * @param faxCountry Country instance + * @param faxAreaCode Area code (without leading zeros) + * @param faxNumber Fax number (without area code and leading zero) + */ + public FaxNumber (final Country faxCountry, final Integer faxAreaCode, final Long faxNumber) { + this.faxCountry = faxCountry; + this.faxAreaCode = faxAreaCode; + this.phoneNumber = faxNumber; + } + + /** + * Protected constructor + */ + protected FaxNumber () { + } @Override public Long getPhoneId () { @@ -99,22 +118,22 @@ public class FaxNumber implements DialableFaxNumber, Comparable + * @param phoneCountry Country instance + * @param phoneAreaCode Phone area code + * @param phoneNumber Phone number + */ + public LandLineNumber (final Country phoneCountry, final Integer phoneAreaCode, final Long phoneNumber) { + this.phoneCountry = phoneCountry; + this.phoneAreaCode = phoneAreaCode; + this.phoneNumber = phoneNumber; + } + + /** + * Protected constructor + */ + protected LandLineNumber () { + } @Override public Long getPhoneId () { @@ -108,12 +127,12 @@ public class LandLineNumber implements DialableLandLineNumber, Comparable. + */ +package org.mxchange.jphone.validators; + +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; +import javax.faces.validator.Validator; +import org.mxchange.jcoreee.validator.number.BaseLongValidator; + +/** + * A validator for phone, fax and mobile numbers + *

+ * @author Roland Haeder + */ +public class PhoneNumberValidator extends BaseLongValidator implements Validator { + + /** + * Serial number + */ + private static final long serialVersionUID = 186_897_817_692_786_900L; + + @Override + public void validate (final FacesContext context, final UIComponent component, final Object value) { + // Trace message + //this.getLogger().logTrace(MessageFormat.format("validate: context={0},component={1},value={2} - CALLED!", context, component, value)); //NOI18N + + // The required field + String[] requiredFileds = {"phoneAreaCode", "phoneNumber", "faxAreaCode", "faxNumber", "cellphoneNumber"}; //NOI18N + + // Pre-validation (example: not null, not a string, empty string ...) + super.preValidate(context, component, value, requiredFileds, true); + + // Trace message + //this.getLogger().logTrace("validate: EXIT!"); //NOI18N + } +}