From: Roland Haeder Date: Mon, 12 Oct 2015 11:48:18 +0000 (+0200) Subject: Rewrite: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=ad792e6206ae5867be6ac6dcbb8870f3f0d5538d;p=jcontacts-core.git Rewrite: - renamed almost all fields - made Country transient as this one should not be entered by the user - fixed index - updated jar(s) Signed-off-by:Roland Häder --- diff --git a/lib/jphone-core.jar b/lib/jphone-core.jar index b8dca2d..414efac 100644 Binary files a/lib/jphone-core.jar and b/lib/jphone-core.jar differ diff --git a/src/org/mxchange/jcontacts/contact/Contact.java b/src/org/mxchange/jcontacts/contact/Contact.java index 9eb87a1..75c6e6c 100644 --- a/src/org/mxchange/jcontacts/contact/Contact.java +++ b/src/org/mxchange/jcontacts/contact/Contact.java @@ -44,56 +44,56 @@ public interface Contact extends Serializable { *

* @return the birthday */ - public Date getBirthday (); + public Date getContactBirthday (); /** * Birth day *

* @param birthday the birthday to set */ - public void setBirthday (final Date birthday); + public void setContactBirthday (final Date birthday); /** * Getter for cellphone number *

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

* @param cellphoneNumber Cellphone number */ - public void setCellphoneNumber (final DialableCellphoneNumber cellphoneNumber); + public void setContactCellphoneNumber (final DialableCellphoneNumber cellphoneNumber); /** * City *

* @return the city */ - public String getCity (); + public String getContactCity (); /** * City *

* @param city the city to set */ - public void setCity (final String city); + public void setContactCity (final String city); /** * Comments *

* @return the comment */ - public String getComment (); + public String getContactComment (); /** * Comments *

* @param comment the comment to set */ - public void setComment (final String comment); + public void setContactComment (final String comment); /** * Id number @@ -114,175 +114,175 @@ public interface Contact extends Serializable { *

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

* @param contactCountry the countryCode to set */ - public void setCountry (final Country contactCountry); + public void setContactCountry (final Country contactCountry); /** * Getter for "created" timestamp *

* @return "created" timestamp */ - public Calendar getCreated (); + public Calendar getContactCreated (); /** * Setter for "created" timestamp *

* @param created "created" timestamp */ - public void setCreated (final Calendar created); + public void setContactCreated (final Calendar created); /** * Email address *

* @return the emailAddress */ - public String getEmailAddress (); + public String getContactEmailAddress (); /** * Email address *

* @param emailAddress the emailAddress to set */ - public void setEmailAddress (final String emailAddress); + public void setContactEmailAddress (final String emailAddress); /** * Family name *

* @return the familyName */ - public String getFamilyName (); + public String getContactFamilyName (); /** * Family name *

* @param familyName the familyName to set */ - public void setFamilyName (final String familyName); + public void setContactFamilyName (final String familyName); /** * Fax number *

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

* @param faxNumber the faxNumber to set */ - public void setFaxNumber (final DialableFaxNumber faxNumber); + public void setContactFaxNumber (final DialableFaxNumber faxNumber); /** * First name *

* @return the first name */ - public String getFirstName (); + public String getContactFirstName (); /** * First name *

* @param firstName the first name to set */ - public void setFirstName (final String firstName); + public void setContactFirstName (final String firstName); /** * Gender of the contact *

* @return the gender */ - public Gender getGender (); + public Gender getContactGender (); /** * Gender of the contact *

* @param gender the gender to set */ - public void setGender (final Gender gender); + public void setContactGender (final Gender gender); /** * House number *

* @return the houseNumber */ - public Short getHouseNumber (); + public Short getContactHouseNumber (); /** * House number *

* @param houseNumber the houseNumber to set */ - public void setHouseNumber (final Short houseNumber); + public void setContactHouseNumber (final Short houseNumber); /** * Setter for own contact *

* @param ownContact Own contact */ - public void setOwnContact (final Boolean ownContact); + public void setContactOwnContact (final Boolean ownContact); /** * Getter for phone number *

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

* @param phoneNumber Phone number */ - public void setPhoneNumber (final DialableLandLineNumber phoneNumber); + public void setContactPhoneNumber (final DialableLandLineNumber phoneNumber); /** * Street *

* @return the street */ - public String getStreet (); + public String getContactStreet (); /** * Street *

* @param street the street to set */ - public void setStreet (final String street); + public void setContactStreet (final String street); /** * Getter for "updated" timestamp *

* @return "updated" timestamp */ - public Calendar getUpdated (); + public Calendar getContactUpdated (); /** * Getter for "updated" timestamp *

* @param updated "updated" timestamp */ - public void setUpdated (final Calendar updated); + public void setContactUpdated (final Calendar updated); /** * ZIP code *

* @return the zipCode */ - public Integer getZipCode (); + public Integer getContactZipCode (); /** * ZIP code *

* @param zipCode the zipCode to set */ - public void setZipCode (final Integer zipCode); + public void setContactZipCode (final Integer zipCode); /** * Checks whether the contact is user's own data diff --git a/src/org/mxchange/jcontacts/contact/UserContact.java b/src/org/mxchange/jcontacts/contact/UserContact.java index d0dd336..20b6fdf 100644 --- a/src/org/mxchange/jcontacts/contact/UserContact.java +++ b/src/org/mxchange/jcontacts/contact/UserContact.java @@ -26,6 +26,7 @@ import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.EnumType; import javax.persistence.Enumerated; +import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; @@ -36,7 +37,6 @@ import javax.persistence.OneToOne; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; -import javax.persistence.Transient; import org.mxchange.jcontacts.contact.gender.Gender; import org.mxchange.jcountry.data.Country; import org.mxchange.jcountry.data.CountryData; @@ -58,8 +58,8 @@ import org.mxchange.jphone.phonenumbers.landline.LandLineNumber; name = "contacts", indexes = { @Index ( - name = "gender", - columnList = "gender" + name = "contact_gender", + columnList = "contact_gender" ) } ) @@ -73,29 +73,29 @@ public class UserContact implements Contact, Comparable { /** * Birth day */ - @Column (name = "birthday") + @Column (name = "contact_birthday") @Temporal (TemporalType.DATE) - private Date birthday; + private Date contactBirthday; /** * Cellphone number */ - @JoinColumn (name = "cellphone_number_id") + @JoinColumn (name = "contact_cellphone_number_id") @OneToOne (targetEntity = CellphoneNumber.class, cascade = CascadeType.ALL) - private DialableCellphoneNumber cellphoneNumber; + private DialableCellphoneNumber contactCellphoneNumber; /** * City */ - @Column (name = "city", nullable = false, length = 100) - private String city; + @Column (name = "contact_city", nullable = false, length = 100) + private String contactCity; /** * Optional comments */ @Lob - @Column (name = "comment") - private String comment; + @Column (name = "contact_comment") + private String contactComment; /** * Id number @@ -109,103 +109,102 @@ public class UserContact implements Contact, Comparable { * Country code */ @JoinColumn (name = "contact_country_id", nullable = false) - @OneToOne(targetEntity = CountryData.class, cascade = CascadeType.ALL, optional = false) - @Transient - private Country country; + @OneToOne(targetEntity = CountryData.class, cascade = CascadeType.ALL, optional = false, fetch = FetchType.EAGER) + private Country contactCountry; /** * When the contact has been created */ @Basic (optional = false) @Temporal (TemporalType.TIMESTAMP) - @Column (name = "created", nullable = false) - private Calendar created; + @Column (name = "contact_created", nullable = false) + private Calendar contactCreated; /** * Email address */ - @Column (name = "email_address", length = 100, nullable = false) - private String emailAddress; + @Column (name = "contact_email_address", length = 100, nullable = false) + private String contactEmailAddress; /** * Family name */ @Basic (optional = false) - @Column (name = "family_name", length = 100, nullable = false) - private String familyName; + @Column (name = "contact_family_name", length = 100, nullable = false) + private String contactFamilyName; /** * Fax number */ - @JoinColumn (name = "fax_number_id") + @JoinColumn (name = "contact_fax_number_id") @OneToOne(targetEntity = FaxNumber.class,cascade = CascadeType.ALL) - private DialableFaxNumber faxNumber; + private DialableFaxNumber contactFaxNumber; /** * First name */ @Basic (optional = false) - @Column (name = "first_name", length = 100, nullable = false) - private String firstName; + @Column (name = "contact_first_name", length = 100, nullable = false) + private String contactFirstName; /** * Gender instance */ @Basic (optional = false) - @Column (name = "gender", nullable = false) + @Column (name = "contact_gender", nullable = false) @Enumerated (EnumType.STRING) - private Gender gender; + private Gender contactGender; /** * House number */ - @Column (name = "house_number", length = 5, nullable = false) - private Short houseNumber; + @Column (name = "contact_house_number", length = 5, nullable = false) + private Short contactHouseNumber; /** * Flag whether this contact is user's own data */ - @Column (name = "own_contact", nullable = false) - private Boolean ownContact; + @Column (name = "contact_own_contact", nullable = false) + private Boolean contactOwnContact; /** * Phone number */ - @JoinColumn (name = "phone_number_id") + @JoinColumn (name = "contact_phone_number_id") @OneToOne (targetEntity = LandLineNumber.class, cascade = CascadeType.ALL) - private DialableLandLineNumber phoneNumber; + private DialableLandLineNumber contactPhoneNumber; /** * Street */ - @Column (name = "street", nullable = false) - private String street; + @Column (name = "contact_street", nullable = false) + private String contactStreet; /** * When the contact has been updated */ @Temporal (TemporalType.TIMESTAMP) - @Column (name = "updated") - private Calendar updated; + @Column (name = "contact_updated") + private Calendar contactUpdated; /** * ZIP code */ - @Column (name = "zip_code", nullable = false, length = 6) - private Integer zipCode; + @Column (name = "contact_zip_code", nullable = false, length = 6) + private Integer contactZipCode; /** - * Constructor for gender and names + * Constructor for contactGender and names *

- * @param gender Gender instance - * @param firstName First name - * @param familyName Family name + * @param contactGender Gender instance + * @param contactFirstName First name + * @param contactFamilyName Family name */ - public UserContact (final Gender gender, final String firstName, final String familyName) { + public UserContact (final Gender contactGender, final String contactFirstName, final String contactFamilyName) { // Set all - this.gender = gender; - this.firstName = firstName; - this.familyName = familyName; + this.contactGender = contactGender; + this.contactFirstName = contactFirstName; + this.contactFamilyName = contactFamilyName; } /** @@ -245,23 +244,23 @@ public class UserContact implements Contact, Comparable { public void copyAll (final Contact contact) { // Copy all: // - base data - this.setFirstName(contact.getFirstName()); - this.setFamilyName(contact.getFamilyName()); - this.setStreet(contact.getStreet()); - this.setZipCode(contact.getZipCode()); - this.setCity(contact.getCity()); - this.setCountry(contact.getCountry()); + this.setContactFirstName(contact.getContactFirstName()); + this.setContactFamilyName(contact.getContactFamilyName()); + this.setContactStreet(contact.getContactStreet()); + this.setContactZipCode(contact.getContactZipCode()); + this.setContactCity(contact.getContactCity()); + this.setContactCountry(contact.getContactCountry()); // - phone, fax, email - this.setPhoneNumber(contact.getPhoneNumber()); - this.setFaxNumber(contact.getFaxNumber()); - this.setCellphoneNumber(contact.getCellphoneNumber()); + this.setContactPhoneNumber(contact.getContactPhoneNumber()); + this.setContactFaxNumber(contact.getContactFaxNumber()); + this.setContactCellphoneNumber(contact.getContactCellphoneNumber()); // - other data - this.setBirthday(contact.getBirthday()); - this.setComment(contact.getComment()); - this.setCreated(contact.getCreated()); - this.setUpdated(contact.getUpdated()); + this.setContactBirthday(contact.getContactBirthday()); + this.setContactComment(contact.getContactComment()); + this.setContactCreated(contact.getContactCreated()); + this.setContactUpdated(contact.getContactUpdated()); } /** @@ -286,49 +285,49 @@ public class UserContact implements Contact, Comparable { Contact contact = (Contact) object; // Now test some data TODO Definedly needs improvement - return ((this.getGender().equals(contact.getGender())) && - (this.getFirstName().toLowerCase().equals(contact.getFirstName().toLowerCase())) && - (this.getFamilyName().toLowerCase().equals(contact.getFamilyName().toLowerCase()))); + return ((this.getContactGender().equals(contact.getContactGender())) && + (this.getContactFirstName().toLowerCase().equals(contact.getContactFirstName().toLowerCase())) && + (this.getContactFamilyName().toLowerCase().equals(contact.getContactFamilyName().toLowerCase()))); } @Override - public Date getBirthday () { - return this.birthday; + public Date getContactBirthday () { + return this.contactBirthday; } @Override - public void setBirthday (final Date birthday) { - this.birthday = birthday; + public void setContactBirthday (final Date contactBirthday) { + this.contactBirthday = contactBirthday; } @Override - public DialableCellphoneNumber getCellphoneNumber () { - return this.cellphoneNumber; + public DialableCellphoneNumber getContactCellphoneNumber () { + return this.contactCellphoneNumber; } @Override - public void setCellphoneNumber (final DialableCellphoneNumber cellphoneNumber) { - this.cellphoneNumber = cellphoneNumber; + public void setContactCellphoneNumber (final DialableCellphoneNumber contactCellphoneNumber) { + this.contactCellphoneNumber = contactCellphoneNumber; } @Override - public String getCity () { - return this.city; + public String getContactCity () { + return this.contactCity; } @Override - public void setCity (final String city) { - this.city = city; + public void setContactCity (final String contactCity) { + this.contactCity = contactCity; } @Override - public String getComment () { - return this.comment; + public String getContactComment () { + return this.contactComment; } @Override - public void setComment (final String comment) { - this.comment = comment; + public void setContactComment (final String contactComment) { + this.contactComment = contactComment; } @Override @@ -342,154 +341,154 @@ public class UserContact implements Contact, Comparable { } @Override - public Country getCountry () { - return this.country; + public Country getContactCountry () { + return this.contactCountry; } @Override - public void setCountry (final Country country) { - this.country = country; + public void setContactCountry (final Country contactCountry) { + this.contactCountry = contactCountry; } @Override - public Calendar getCreated () { - return this.created; + public Calendar getContactCreated () { + return this.contactCreated; } @Override - public void setCreated (final Calendar created) { - this.created = created; + public void setContactCreated (final Calendar contactCreated) { + this.contactCreated = contactCreated; } @Override - public String getEmailAddress () { - return this.emailAddress; + public String getContactEmailAddress () { + return this.contactEmailAddress; } @Override - public void setEmailAddress (final String emailAddress) { - this.emailAddress = emailAddress; + public void setContactEmailAddress (final String contactEmailAddress) { + this.contactEmailAddress = contactEmailAddress; } @Override - public String getFamilyName () { + public String getContactFamilyName () { //* NOISY-DEBUG: */ this.getLogger().logTrace("CALLED!"); - return this.familyName; + return this.contactFamilyName; } @Override - public void setFamilyName (final String familyName) { - this.familyName = familyName; + public void setContactFamilyName (final String contactFamilyName) { + this.contactFamilyName = contactFamilyName; } @Override - public DialableFaxNumber getFaxNumber () { - return this.faxNumber; + public DialableFaxNumber getContactFaxNumber () { + return this.contactFaxNumber; } @Override - public void setFaxNumber (final DialableFaxNumber faxNumber) { - this.faxNumber = faxNumber; + public void setContactFaxNumber (final DialableFaxNumber contactFaxNumber) { + this.contactFaxNumber = contactFaxNumber; } @Override - public String getFirstName () { - return this.firstName; + public String getContactFirstName () { + return this.contactFirstName; } @Override - public void setFirstName (final String firstName) { - this.firstName = firstName; + public void setContactFirstName (final String contactFirstName) { + this.contactFirstName = contactFirstName; } @Override - public Gender getGender () { - return this.gender; + public Gender getContactGender () { + return this.contactGender; } @Override - public void setGender (final Gender gender) { - this.gender = gender; + public void setContactGender (final Gender contactGender) { + this.contactGender = contactGender; } @Override - public Short getHouseNumber () { - return this.houseNumber; + public Short getContactHouseNumber () { + return this.contactHouseNumber; } @Override - public void setHouseNumber (final Short houseNumber) { - this.houseNumber = houseNumber; + public void setContactHouseNumber (final Short contactHouseNumber) { + this.contactHouseNumber = contactHouseNumber; } @Override - public void setOwnContact (final Boolean ownContact) { - this.ownContact = ownContact; + public void setContactOwnContact (final Boolean contactOwnContact) { + this.contactOwnContact = contactOwnContact; } @Override - public DialableLandLineNumber getPhoneNumber () { - return this.phoneNumber; + public DialableLandLineNumber getContactPhoneNumber () { + return this.contactPhoneNumber; } @Override - public void setPhoneNumber (final DialableLandLineNumber phoneNumber) { - this.phoneNumber = phoneNumber; + public void setContactPhoneNumber (final DialableLandLineNumber contactPhoneNumber) { + this.contactPhoneNumber = contactPhoneNumber; } @Override - public String getStreet () { - return this.street; + public String getContactStreet () { + return this.contactStreet; } @Override - public void setStreet (final String street) { - this.street = street; + public void setContactStreet (final String contactStreet) { + this.contactStreet = contactStreet; } @Override - public Calendar getUpdated () { - return this.updated; + public Calendar getContactUpdated () { + return this.contactUpdated; } @Override - public void setUpdated (final Calendar updated) { - this.updated = updated; + public void setContactUpdated (final Calendar contactUpdated) { + this.contactUpdated = contactUpdated; } @Override - public Integer getZipCode () { - return this.zipCode; + public Integer getContactZipCode () { + return this.contactZipCode; } @Override - public void setZipCode (final Integer zipCode) { - this.zipCode = zipCode; + public void setContactZipCode (final Integer contactZipCode) { + this.contactZipCode = contactZipCode; } @Override public int hashCode () { - // Validate gender instance - assert (this.getGender() instanceof Gender) : "gender is not set."; //NOI18N + // Validate contactGender instance + assert (this.getContactGender() instanceof Gender) : "gender is not set."; //NOI18N int hash = 7; - hash = 79 * hash + Objects.hashCode(this.getFamilyName()); - hash = 79 * hash + this.getGender().hashCode(); - hash = 79 * hash + Objects.hashCode(this.getFirstName()); + hash = 79 * hash + Objects.hashCode(this.getContactFamilyName()); + hash = 79 * hash + this.getContactGender().hashCode(); + hash = 79 * hash + Objects.hashCode(this.getContactFirstName()); return hash; } /** - * Initialization with fake gender UNKNOWN + * Initialization with fake contactGender UNKNOWN */ @PostConstruct public void init () { - // Fake gender - this.gender = Gender.UNKNOWN; + // Fake contactGender + this.contactGender = Gender.UNKNOWN; } @Override public Boolean isOwnContact () { - return this.ownContact; + return this.contactOwnContact; } } diff --git a/src/org/mxchange/jcontacts/contact/gender/GenderUtils.java b/src/org/mxchange/jcontacts/contact/gender/GenderUtils.java index a4910ff..5535c21 100644 --- a/src/org/mxchange/jcontacts/contact/gender/GenderUtils.java +++ b/src/org/mxchange/jcontacts/contact/gender/GenderUtils.java @@ -44,13 +44,13 @@ public class GenderUtils extends BaseFrameworkSystem { if (null == contact) { // Abort here throw new NullPointerException("contact is null"); - } else if (contact.getGender() == null) { + } else if (contact.getContactGender() == null) { // Gender is not set throw new NullPointerException(MessageFormat.format("contact {0} has no gender set.", contact)); } // Get key from it - String key = contact.getGender().getMessageKey(); + String key = contact.getContactGender().getMessageKey(); // Translate and return it return utils.getMessageStringFromKey(key); diff --git a/src/org/mxchange/jcontacts/exceptions/ContactAlreadyAddedException.java b/src/org/mxchange/jcontacts/exceptions/ContactAlreadyAddedException.java index 1b8e63d..8b1f558 100644 --- a/src/org/mxchange/jcontacts/exceptions/ContactAlreadyAddedException.java +++ b/src/org/mxchange/jcontacts/exceptions/ContactAlreadyAddedException.java @@ -37,7 +37,7 @@ public class ContactAlreadyAddedException extends Exception { * @param contact Contact that is already added */ public ContactAlreadyAddedException (final Contact contact) { - super(MessageFormat.format("Contact with gender={0}, firstName={1} and familyName={2} already added.", contact.getGender(), contact.getFirstName(), contact.getFamilyName())); + super(MessageFormat.format("Contact with gender={0}, firstName={1} and familyName={2} already added.", contact.getContactGender(), contact.getContactFirstName(), contact.getContactFamilyName())); } /**