From: Roland Haeder Date: Sat, 10 Oct 2015 20:02:50 +0000 (+0200) Subject: Rewrite: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=24c4a3aef7e2de8b4823cd212d803b76e781f5ac;p=jcontacts-core.git Rewrite: - introduced jcountry-core which is a library for handling country-related data, e.g. dial prefix, country code ... - introduced jphone-core which is a library for handling phone, fax and cell phone numbers - these both new libraries required a rewrite of many parts --- diff --git a/.gitignore b/.gitignore index 315ea15..0383bcc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ -/dist/ +/nbproject/private/ +/nbproject/*~ +/manifest.mf /build/ -/nbproject/private/ \ No newline at end of file +/dist/ +/data/* +/*.properties diff --git a/lib/jcore.jar b/lib/jcore.jar index 57a3b6c..1a75fc0 100644 Binary files a/lib/jcore.jar and b/lib/jcore.jar differ diff --git a/lib/jcountry-core.jar b/lib/jcountry-core.jar new file mode 100644 index 0000000..ed08999 Binary files /dev/null and b/lib/jcountry-core.jar differ diff --git a/lib/jphone-core.jar b/lib/jphone-core.jar new file mode 100644 index 0000000..480f9f8 Binary files /dev/null and b/lib/jphone-core.jar differ diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml index 48a76ad..032b3c2 100644 --- a/nbproject/build-impl.xml +++ b/nbproject/build-impl.xml @@ -18,1421 +18,1421 @@ is divided into following sections: - applet - cleanup ---> + --> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set src.dir - Must set test.src.dir - Must set build.dir - Must set dist.dir - Must set build.classes.dir - Must set dist.javadoc.dir - Must set build.test.classes.dir - Must set build.test.results.dir - Must set build.classes.excludes - Must set dist.jar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - No tests executed. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set JVM to use for profiling in profiler.info.jvm - Must set profiler agent JVM arguments in profiler.info.jvmargs.agent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - java -jar "${dist.jar.resolved}" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - Must select one file in the IDE or set run.class - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set debug.class - - - - - Must select one file in the IDE or set debug.class - - - - - Must set fix.includes - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - Must select one file in the IDE or set profile.class - This target only works when run from inside the NetBeans IDE. - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - - - Must select some files in the IDE or set test.includes - - - - - Must select one file in the IDE or set run.class - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - Some tests failed; see details above. - - - - - - - - - Must select some files in the IDE or set test.includes - - - - Some tests failed; see details above. - - - - Must select some files in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - Some tests failed; see details above. - - - - - Must select one file in the IDE or set test.class - - - - Must select one file in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - - - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nbproject/project.properties b/nbproject/project.properties index d3eff02..7c117d2 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -31,12 +31,16 @@ dist.javadoc.dir=${dist.dir}/javadoc endorsed.classpath= excludes= file.reference.jcore.jar=lib/jcore.jar +file.reference.jcountry-core.jar=lib/jcountry-core.jar +file.reference.jphone-core.jar=lib/jphone-core.jar includes=** jar.archive.disabled=${jnlp.enabled} jar.compress=false jar.index=${jnlp.enabled} javac.classpath=\ ${file.reference.jcore.jar}:\ + ${file.reference.jcountry-core.jar}:\ + ${file.reference.jphone-core.jar}:\ ${libs.jpa20-persistence.classpath} # Space-separated list of extra javac options javac.compilerargs=-Xlint:unchecked -Xlint:deprecation @@ -90,5 +94,7 @@ run.test.classpath=\ ${build.test.classes.dir} source.encoding=UTF-8 source.reference.jcore.jar=../jcore/src/ +source.reference.jcountry-core.jar=../jcountry-core/src/ +source.reference.jphone-core.jar=../jphone-core/src/ src.dir=src test.src.dir=test diff --git a/nbproject/project.xml b/nbproject/project.xml index 7e13b08..8a8b12e 100644 --- a/nbproject/project.xml +++ b/nbproject/project.xml @@ -1,18 +1,18 @@ - org.netbeans.modules.java.j2seproject - - - jcontacts-core - - - - - - - - - .\lib\nblibraries.properties - - + org.netbeans.modules.java.j2seproject + + + jcontacts-core + + + + + + + + + .\lib\nblibraries.properties + + diff --git a/src/org/mxchange/jcontacts/contact/Contact.java b/src/org/mxchange/jcontacts/contact/Contact.java index 1ecef44..9eb87a1 100644 --- a/src/org/mxchange/jcontacts/contact/Contact.java +++ b/src/org/mxchange/jcontacts/contact/Contact.java @@ -20,6 +20,10 @@ import java.io.Serializable; import java.util.Calendar; import java.util.Date; import org.mxchange.jcontacts.contact.gender.Gender; +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; /** * A general contact interface @@ -50,18 +54,18 @@ public interface Contact extends Serializable { public void setBirthday (final Date birthday); /** - * Cellphone number + * Getter for cellphone number *

- * @return the cellphoneNumber + * @return Cellphone number */ - public String getCellphoneNumber (); + public DialableCellphoneNumber getCellphoneNumber (); /** - * Cellphone number + * Setter for cellphone number *

- * @param cellphoneNumber the cellphoneNumber to set + * @param cellphoneNumber Cellphone number */ - public void setCellphoneNumber (final String cellphoneNumber); + public void setCellphoneNumber (final DialableCellphoneNumber cellphoneNumber); /** * City @@ -110,14 +114,14 @@ public interface Contact extends Serializable { *

* @return the countryCode */ - public String getCountryCode (); + public Country getCountry (); /** * Country code *

- * @param countryCode the countryCode to set + * @param contactCountry the countryCode to set */ - public void setCountryCode (final String countryCode); + public void setCountry (final Country contactCountry); /** * Getter for "created" timestamp @@ -166,14 +170,14 @@ public interface Contact extends Serializable { *

* @return the faxNumber */ - public String getFaxNumber (); + public DialableFaxNumber getFaxNumber (); /** * Fax number *

* @param faxNumber the faxNumber to set */ - public void setFaxNumber (final String faxNumber); + public void setFaxNumber (final DialableFaxNumber faxNumber); /** * First name @@ -225,18 +229,18 @@ public interface Contact extends Serializable { public void setOwnContact (final Boolean ownContact); /** - * Phone number + * Getter for phone number *

- * @return the phoneNumber + * @return Phone number */ - public String getPhoneNumber (); + public DialableLandLineNumber getPhoneNumber (); /** - * Phone number + * Setter for phone number *

- * @param phoneNumber the phoneNumber to set + * @param phoneNumber Phone number */ - public void setPhoneNumber (final String phoneNumber); + public void setPhoneNumber (final DialableLandLineNumber phoneNumber); /** * Street diff --git a/src/org/mxchange/jcontacts/contact/UserContact.java b/src/org/mxchange/jcontacts/contact/UserContact.java index bfb6ab6..b48a2e0 100644 --- a/src/org/mxchange/jcontacts/contact/UserContact.java +++ b/src/org/mxchange/jcontacts/contact/UserContact.java @@ -21,6 +21,7 @@ import java.util.Date; import java.util.Objects; import javax.annotation.PostConstruct; import javax.persistence.Basic; +import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.EnumType; @@ -28,11 +29,22 @@ import javax.persistence.Enumerated; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.Index; +import javax.persistence.JoinColumn; import javax.persistence.Lob; +import javax.persistence.OneToOne; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; import org.mxchange.jcontacts.contact.gender.Gender; +import org.mxchange.jcountry.data.Country; +import org.mxchange.jcountry.data.CountryData; +import org.mxchange.jphone.phonenumbers.cellphone.CellphoneNumber; +import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber; +import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber; +import org.mxchange.jphone.phonenumbers.fax.FaxNumber; +import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber; +import org.mxchange.jphone.phonenumbers.landline.LandLineNumber; /** * A general contact class which should only be extended. @@ -41,7 +53,15 @@ import org.mxchange.jcontacts.contact.gender.Gender; * @version 0.0 */ @Entity (name = "contacts") -@Table (name = "contacts") +@Table ( + name = "contacts", + indexes = { + @Index ( + name = "gender", + columnList = "gender" + ) + } +) public class UserContact implements Contact, Comparable { /** @@ -59,8 +79,9 @@ public class UserContact implements Contact, Comparable { /** * Cellphone number */ - @Column (name = "cellphone_number", length = 100) - private String cellphoneNumber; + @JoinColumn (name = "cellphone_number_id") + @OneToOne (targetEntity = CellphoneNumber.class, cascade = CascadeType.ALL) + private DialableCellphoneNumber cellphoneNumber; /** * City @@ -86,8 +107,9 @@ public class UserContact implements Contact, Comparable { /** * Country code */ - @Column (name = "country_code", length = 2, nullable = false) - private String countryCode; + @JoinColumn (name = "contact_country_id", nullable = false) + @OneToOne(targetEntity = CountryData.class, cascade = CascadeType.ALL, optional = false) + private Country country; /** * When the contact has been created @@ -113,8 +135,9 @@ public class UserContact implements Contact, Comparable { /** * Fax number */ - @Column (name = "fax_number", length = 100) - private String faxNumber; + @JoinColumn (name = "fax_number_id") + @OneToOne(targetEntity = FaxNumber.class,cascade = CascadeType.ALL) + private DialableFaxNumber faxNumber; /** * First name @@ -146,8 +169,9 @@ public class UserContact implements Contact, Comparable { /** * Phone number */ - @Column (name = "phone_number", length = 100) - private String phoneNumber; + @JoinColumn (name = "phone_number_id") + @OneToOne (targetEntity = LandLineNumber.class, cascade = CascadeType.ALL) + private DialableLandLineNumber phoneNumber; /** * Street @@ -224,7 +248,7 @@ public class UserContact implements Contact, Comparable { this.setStreet(contact.getStreet()); this.setZipCode(contact.getZipCode()); this.setCity(contact.getCity()); - this.setCountryCode(contact.getCountryCode()); + this.setCountry(contact.getCountry()); // - phone, fax, email this.setPhoneNumber(contact.getPhoneNumber()); @@ -276,12 +300,12 @@ public class UserContact implements Contact, Comparable { } @Override - public String getCellphoneNumber () { + public DialableCellphoneNumber getCellphoneNumber () { return this.cellphoneNumber; } @Override - public void setCellphoneNumber (final String cellphoneNumber) { + public void setCellphoneNumber (final DialableCellphoneNumber cellphoneNumber) { this.cellphoneNumber = cellphoneNumber; } @@ -316,13 +340,13 @@ public class UserContact implements Contact, Comparable { } @Override - public String getCountryCode () { - return this.countryCode; + public Country getCountry () { + return this.country; } @Override - public void setCountryCode (final String countryCode) { - this.countryCode = countryCode; + public void setCountry (final Country country) { + this.country = country; } @Override @@ -357,12 +381,12 @@ public class UserContact implements Contact, Comparable { } @Override - public String getFaxNumber () { + public DialableFaxNumber getFaxNumber () { return this.faxNumber; } @Override - public void setFaxNumber (final String faxNumber) { + public void setFaxNumber (final DialableFaxNumber faxNumber) { this.faxNumber = faxNumber; } @@ -402,12 +426,12 @@ public class UserContact implements Contact, Comparable { } @Override - public String getPhoneNumber () { + public DialableLandLineNumber getPhoneNumber () { return this.phoneNumber; } @Override - public void setPhoneNumber (final String phoneNumber) { + public void setPhoneNumber (final DialableLandLineNumber phoneNumber) { this.phoneNumber = phoneNumber; }